When a file is deleted from the Drupal site it is still accessible until Varnish cache is cleared.
You can 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).
Creating a custom caching policy:
- Creating custom caching policy per file type
- Set max-age headers for specific pages, files, or paths
Acquia recommends that you thoroughly test any changes to reducing cache as this could increase the load on your servers and impact site performance.
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 for your file to be deleted in the 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.