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.
I'm not sure if this is something file_entity even has control over, or if supplemental modules are needed.
I am working on a site hosted on the Acquia Managed Cloud. The hosting architecture includes a Varnish cache.
When I replace a public file (e.g. a PDF file) in an existing File Entity with a file of the same name, the old file remains cached in Varnish until the cache expires. Is there a way to trigger invalidation of the Varnish cache entry when a file is replaced?
Comment | File | Size | Author |
---|---|---|---|
#8 | replacing_file_varnish-1979996-8.patch | 559 bytes | undertext |
Comments
Comment #1
Dave ReidI'm not well versed enough in Varnish to know. Public files may also be a problem since they're served directly and Drupal cannot insert any type of headers into those responses.
Comment #2
paulmckibbenThanks! A short term solution for us may be to shorten the cache expiration times for files. Makes sense that public files would be purely under the control of Varnish and Apache (Drupal not involved).
Does anyone reading this know if there is any complementary module that will invalidate a varnish cache entry when a file entity is edited? Has anyone tried the expire module with File Entity?
Comment #3
gmclelland CreditAttribution: gmclelland commentedWhat about #1701924: Add a cache-busting string to images?
Comment #4
paulmckibbenI did get some advice from Acquia on this about using curl to send some purge headers from a command line. The purge headers are proprietary to the site, so I can't paste them here (nor would they be useful to anyone else anyway).
The command is along the lines of:
Comment #5
acbramley CreditAttribution: acbramley commentedHey! What modules are you using in Drupal for your varnish setup? We use the expire and purge modules to automatically expire/purge paths. I recently wrote a patch for this which adds in the automatic expiration on files. It is now committed on the 7.x-2.x branch so I would highly recommend checking it out! It will expire the file paths on delete and update.
Cheers
Comment #6
Devin Carlson CreditAttribution: Devin Carlson commentedFrom the request in #2 and the response in #5 it sounds like this is now fixed by using the latest versions of the expire and purge modules.
Comment #7.0
(not verified) CreditAttribution: commentedClarified that Varnish is part of the hosting architecture I am using.
Comment #8
undertext CreditAttribution: undertext commentedHi all. Have the same problem. I tried to use expire module to solve this issue but unfortunately 'file_unmanaged_copy' do not call any hooks that can inform about file have been changed.
How about to call 'file_update' hook on file replace?
Patch attached.
Comment #9
Dave Reidfile_save() will call hook_file_update for us. Why would this be necessary?
Comment #10
Dave ReidComment #11
Dave ReidMoving back to closed due to lack of response.