ImageStyleDownloadController::deliver does not send cache headers when caching is enabled

Created on 1 March 2014, almost 11 years ago
Updated 15 May 2023, over 1 year ago

Updated: Comment #0

Problem/Motivation

In ImageStyleDownloadController::deliver Drupal sends the generated imagecache picture back to the Client and it does this with the two Headers 'Content-Type' and 'Content-Length'.
The Problem is that no Cache Headers are sent to the Client even when Caching in Drupal is enabled. So the Drupal default caches like "Cache-Control: no-cache" are sent.
This is for normal Sites not such an issue, as the next request will then hit the Webserver File directory and for this the file is delivered without PHP and most probably the correct headers are set (because of Header Settings in .htaccess).
But if Varnish or maybe also other Reverse-Proxy-Caches are used, it can happen that a hit_for_pass is generated. This basically tells Varnish to pass every future request directly to the backend (for a specific amount of time). This happens when Varnish realizes that a request which normally should be cached (access to image) is returned "no-cache". This means that for a short time, every request to this picture will be done to the backend, which could maybe kill some Servers.

Proposed resolution

Check in ImageStyleDownloadController::deliver if caching is enabled and add some Caching headers like we do in drupal_serve_page_from_cache()

Remaining tasks

  • Write Code
  • Write Tests

User interface changes

- none

API changes

-none

πŸ“Œ Task
Status

Closed: outdated

Version

9.5

Component
Image systemΒ  β†’

Last updated 1 day ago

Created by

πŸ‡¨πŸ‡­Switzerland Schnitzel

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.

Production build 0.71.5 2024