mod_expires is ignored for files delivered through FileDownloadController

Created on 10 February 2022, over 2 years ago
Updated 18 January 2023, over 1 year ago

When using FileDownloadController::download() with a file a public file scheme, \Symfony\Component\HttpFoundation\BinaryFileResponse will set a header Cache-Control: public. Which itself is fine, but it's missing a max-age. This is preventing assets from being cached. Possibly it's expected that anything implementing a BinaryFileResponse would add max-age to the header.

In Drupal's case, we normally use mod_expires, as there is default code that comes with Drupal's htaccess. (I say normally as it's dependent on server configuration, but I think it's fairly standard practise to use this for setting cache headers on file assets).
However, mod_expires does not override existing headers, they need to not already exist on the response for it to work.

I've marked this as a minor, as it's probably a fairly low impact. In our case we are using the Flysystem module, which streams files through FileDownloadController::download(). We want our aggregated CSS/JS to be cached in the users browser.

🐛 Bug report
Status

Active

Version

10.1

Component
File system 

Last updated 1 day ago

Created by

🇬🇧United Kingdom Leon Kessler

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024