Issue
Files are not being updated when a new file is uploaded.
Cause
File cache time is set independently of your website's cache duration. The cache time on files is set in the .htaccess file, and the default is two weeks:
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
This means you could have to wait up to two weeks to see your new file in a browser, as the file will be cached in the users' local browser caches and Varnish cache for up to two weeks. Note: these files can still be stored in local browser caches despite clearing Drupal and/or Varnish cache.
You can see the cache time on the file by requesting it using curl from the command line, the max-age=1209600 value (which is in seconds, and equals two weeks) in the output:
$ curl -sLIXGET www.websiteurl.com/link/to/file.pdf
{..SNIP..}
Cache-Control: max-age=1209600
Resolution
The easiest way to resolve this issue is to upload the file with a new file name to differentiate it (for example append a number to the end of the file name), and then update the corresponding locations where it is being used. We recommend that after uploading the new file, delete the old file (from the server) to keep the file storage under control.
Alternatively, you could implement a reduced cache duration for specific files, however any local browser cached copies of the file will remain there for up to two weeks and it will only be new requests to the specific files that will respect this change (once implemented). We advise against turning the caching off or setting the max-age to 0 as this may open your site up to a potential DDoS vector.
Acquia recommends that you thoroughly test any changes to reducing cache as this could increase the load on your servers and impact site performance.
Creating a custom caching policy:
- Creating custom caching policy per file type
- Set max-age headers for specific pages, files, or paths