Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Currently images styled with effects does not deliver cache tags that leads to problem on external caches (Varnish tested) - no cache invalidation happens.
That's because the generated images responce does not have cache tags in responce
Proposed resolution
Pass cache tags from image style within ImageStyleDownloadController::deliver()
Remaining tasks
discus, patch, commit
User interface changes
no
API changes
no
Data model changes
no
Comments
Comment #2
andypostComment #3
andypostFiled contrib module
varnish_purge
issue #2908284: Purge image styles by URLthere's also a case when varnish restarted so image-styled files will be delivered by web-server so no way to pass cache tags
Comment #4
BerdirCopy & paste from IRC:
The controller only delivers the image the first time when it is generated. once it has been written to the file system, there is nothing that Drupal can do to add cache tags there. The crop module solves this by adding a hash of the crop information to the image url so the url changes when the crop configuration changes
Comment #5
Wim Leers#4++
Comment #6
BerdirAs discussed with Wim in IRC, there's not much core can do without severe performance regressions (like a force a redirect through Drupal on every request) and varnish-specific implementations like listening on image style configuration changes and pushing them somehow to varnish would need to be done in e.g. the varnish module.
Comment #7
MiSc CreditAttribution: MiSc commentedHave now added basic support for this in the Varnish purger.