Make the response cacheable

Created on 28 November 2023, 7 months ago
Updated 17 June 2024, 8 days ago

Problem/Motivation

The file download response from the media route is currently not cached.

This impacts two parts:

  • The response is not cached in Drupal.
  • No cache tags and cache info are sent with the response, so it won't be cached in Varnish. Or worse, if it is cached due to the Varnish config, then it won't be properly purged.

Steps to reproduce

Without Varnish:
Create media, upload pdf.
Visit the media as anonymous.
Put a debug break point or something to detect a controller hit.
Refresh the page.

Expected: Controller is not called on repeated request, cached response is served.
Actual: Controller is called again on repeated request.

With Varnish:
Configure Varnish to cache all anonymous requests with TTL e.g. 8h.
(you can argue whether this is a good or bad idea)
Use a purge module like dropsolid_purge. (the one we use does not purge urls, maybe this is the problem)
Create media, upload pdf.
Visit the media as anonymous.
Update the media, upload a different pdf.
Visit again the media as anonymous.

Expected: Anonymous sees the updated pdf.
Actual: Anonymous sees the old pdf, because it was not purged.

Proposed resolution

Cache the response.
Set cache metadata in the response, which can be picked up by purge module to add the respective headers.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Fixed

Version

2.1

Component

Miscellaneous

Created by

πŸ‡©πŸ‡ͺGermany donquixote

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024