Implement HTTP caching with max-age on diffs_batch.json
Background
As discussed in #381607 (closed), we can utilize the built-in HTTP caching of browsers (Chrome seems to have a bug though) by setting max-age via Cache-Control headers. This way, when client hits the same request it'll used the one in the browser's cache instead.
Proposal
- Set
Cache-Control: max-age=86400, privateheader fordiffs_batch.jsonwhenckparam (short for cache key) is present and we're displaying the HEAD diff. - Set the
cache_keyin theProject::MergeRequestsController#showtemplate so it can be used by frontend. For now, this can be theidof the HEADMergeRequestDiff. - Introduce this behind a feature flag.
Specifically targetting HEAD diff for now since it's the default diff we show on the MR changes tab. We can iterate for other diff versions later on.