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?

CommentFileSizeAuthor
#8 replacing_file_varnish-1979996-8.patch559 bytesundertext
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

I'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.

paulmckibben’s picture

Thanks! 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?

gmclelland’s picture

paulmckibben’s picture

I 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:

curl -X PURGE -H "(custom purge header)" -H "Accept-Encoding: gzip" http://yourdomain.example.com/sites/default/files/testdocument.pdf
acbramley’s picture

Hey! 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

Devin Carlson’s picture

Status: Active » Fixed

From 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Clarified that Varnish is part of the hosting architecture I am using.

undertext’s picture

Version: 7.x-2.0-unstable6 » 7.x-2.x-dev
Issue summary: View changes
Status: Closed (fixed) » Needs review
FileSize
559 bytes

Hi 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.

Dave Reid’s picture

file_save() will call hook_file_update for us. Why would this be necessary?

Dave Reid’s picture

Status: Needs review » Needs work
Dave Reid’s picture

Status: Needs work » Closed (fixed)

Moving back to closed due to lack of response.