Skip to content

Cache markdown when viewing a blob

Patrick Bajao requested to merge 262045-cached-markdown-blob into master

What does this MR do?

In order to improve performance of Projects::BlobController#show.json when viewing a markdown blob, we need to utilize the cache so succeeding requests to the same blob won't have to re-parse markdown.

This utilizes the cache_key option of Banzai::Renderer#render method which will be called in the code path of markup helper. The cache key will follow the format of: cache:gitlab:banzai/blob/<id>/commit/<commit_id>/full. It expires in 2 weeks.

Based on tests done locally, this improves the response time of the endpoint when viewing a large markdown file from ~11s to ~4s when cached. This is for viewing a 700kb markdown file. It'll take ~350kb when cached in redis.

This is behind a feature flag called cached_markdown_blob. Planning to roll it out on gitlab-org/gitlab project first to see how much cache space will it use on production.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team

#262045 (closed)

Edited by Patrick Bajao

Merge request reports