Cache markdown when viewing blob
In #223043 (closed), it was reported that rendering a big markdown file (when viewed as a blob) is slow. We are not utilizing the cache when we parse the markdown so we have to do it all the time, even if the content didn't change.
Proposal
The Banzai::Rendered.render
has an existing caching mechanism but it's not being utilized in Projects::BlobController#show
. It can be used when cache_key
exists in the context
argument. The caching mechanism utilizes Rails.cache
which will automatically expire after 2 weeks.
Use the caching mechanism and set the cache_key
based on blob's id
and commit_id
. This way, each version of the file can be cached when read.
Feature flag
This is introduced behind the cached_markdown_blob
feature flag.
Edited by Patrick Bajao