apache.htaccesspurge

How to purge Apache to force browser to clear cache and load files?


I edited some css files and need the Apache to do a purge to clear the cache on all browsers, forcing a complete site reload. I have used cloudflare in the past and they had a button to do this called "Purge all files". I relied on this for when I made css file changes.

I have the following in my .htaccess file:

ExpiresByType text/css A31536000

That I know is causing my cache to hold onto the old file. My host provider said that I did not have setting applied to cache files from my server.

I went into my .htaccess file and changed this line to:

ExpiresByType text/css A10

in an attempt to manually "purge" my files and force the css file to reload. This unfortunately did not work.

Does anyone know what I can do in my htaccess file to force a user's browser to reload this css file?


Solution

  • I know this pain Paul. Try adding this to your .htaccess:

    ExpiresActive On
    ExpiresDefault A1
    Header append Cache-Control must-revalidate
    

    I use this when I'm making changes to a website and it seems to work well. However, for people who've previously cached your website, I don't think there is a true way to force a refresh.