Closed (outdated)
Project:
Drupal core
Version:
11.x-dev
Component:
dynamic_page_cache.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Aug 2021 at 03:50 UTC
Updated:
18 Nov 2025 at 15:31 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Oscaner commentedComment #3
jeroentComment #4
Oscaner commentedReroll on D9.2.x
Comment #8
catchWhat are you trying to cache BinaryFileResponse in that's not the dynamic page cache? BinaryFileResponse is a Symfony class and doesn't implement the interface, so would never enter the cache in the first place due to the CacheableResponse check in ::onRequest(). I'm not sure why we'd special case an interface that already doesn't implement CacheableResponseInterface by default.
If this is for custom code, you can add a dynamic page cache response policy to exclude BinaryFileResponse - that would allow you to implement the interface but still exclude it from dynamic page cache. I could see someone trying to do similar but also trying to make things serializable too, in which case the hard-coding of the interface here would prevent that.
Moving to needs more info until the use case is clearer.
Comment #9
donquixote commentedI just ran into this.
The CacheableResponseInterface has two effects:
1. The page can be cached in Drupal's dynamic page cache.
2. The page gets cache tag headers and can be cached in Varnish.
The Media Alias Display module replaces the media controller and sends a BinaryFileResponse when visiting a media canonical url.
The module currently does not add any cache info to the response, making it uncacheable.
Our own varnish config auto-caches everything for anonymous for 8h.
This means that now these files are not purged on update, because Varnish does not have the cache tags.
My solution attempt is to create this class:
Now I only need to figure out which cache tags and cache contexts to add...
Comment #10
donquixote commentedLink to #3404512: Make the response cacheable for Media Alias Display.
Comment #12
smustgrave commentedWith the fix in for media alias display is this still needed?
Comment #13
smustgrave commentedSince the contrib module was fixed not sure this one is needed.