Issue Bug Under Review

#111638File dump sends empty Cache-Control header for files of non-public storages

Kevin Meckl 11/27/26, 11:30 updated 11/27/26, 13:43

Description

Files of a non-public storage are delivered through the file dump (eID=dumpFile). The response contains Last-Modified, but an empty Cache-Control header. Browsers then cache the protected file heuristically, also after logout.

Prerequisites

  • TYPO3 14.3.12 (composer mode), PHP 8.5, Apache 2.4
  • A non-public storage: local driver, base path outside the document root, “Is publicly available?” disabled
  • Optional: a listener for ModifyFileDumpEvent that allows the download for logged-in frontend users only

Steps to reproduce the problem

  1. Create a non-public storage as described above and upload a PDF file into it.
  2. Link the file in a text element of a frontend page, so a file dump URL (index.php?eID=dumpFile&...&token=...) is generated.
  3. Open the page in the frontend and request the file dump URL, e.g. with curl -I.
  4. Inspect the response headers.

Actual results

The file is sent with Last-Modified, but without a Cache-Control directive:

Content-Disposition: inline; filename="example.pdf"
Content-Type: application/pdf
Last-Modified: Thu, 15 May 2025 15:22:06 GMT
Cache-Control:

The header is set empty on purpose in LocalDriver::streamFile() and ResourceStorage::getPseudoStream():

// Cache-Control header is needed here to solve an issue with browser IE8 and lower
// See for more information: http://support.microsoft.com/kb/323308
'Cache-Control' => '',

Without a Cache-Control directive, browsers apply heuristic caching based on Last-Modified (RFC 9111, section 4.2.2), typically 10 % of the time since the last modification. A file modified a year ago may be reused from the browser cache for about five weeks. As a result:

  • A protected file stays in the browser cache after logout and can be opened by the next user of a shared device.
  • Shared caches and CDNs may store the response, depending on their configuration.
  • A file replaced under the same name is delivered outdated for weeks.

The result is repeatable.

Expected results

Files of a non-public storage are sent with Cache-Control: private, no-store, so neither shared caches nor the browser store them.

Additional notes

  • The IE8 workaround is obsolete.
  • ModifyFileDumpEvent is dispatched before the file is streamed, so a listener cannot add a header to the final response. It can only replace the whole response, and then has to re-implement the cropping and scaling (cv, s) of FileDumpController::dumpAction().

Suggested fix:

  1. Remove the empty Cache-Control header from LocalDriver::streamFile() and ResourceStorage::getPseudoStream().
  2. Send Cache-Control: private, no-store in FileDumpController::dumpAction() for files of a non-public storage. The controller validates the token and knows the storage of the file, a driver does not know whether its storage is public.
  3. Files of public storages and responses set by a listener of ModifyFileDumpEvent stay unchanged.

—-

Reviews 1

History 12

  1. Kevin Meckl changed is private 11/27/26, 11:43

  2. Gerrit Code Review pushed patch set 2 for main to change 98107 status New Under Review 11/27/26, 13:43