Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 617
Paul Avatar asked Jul 25 '18 20:07

Paul


People also ask

How do I force browser to clear cache?

But you can bypass the cache and force a complete refresh by using some simple hotkeys: Windows and Linux browsers: CTRL + F5. Apple Safari: SHIFT + Reload toolbar button. Chrome and Firefox for Mac: CMD + SHIFT + R.

How do I purge Apache cache?

Open the Apache caching PHP utility by typing "htcacheclean -r" into the terminal window. When this is completed, press "Enter" on the keyboard to formally launch the cache cleaning. During this process, the server utility thoroughly cleans and deletes any superfluous subdirectories on the server.

How do I clear HTML cache?

Here's how to clear the browser cache for just one web page: Open the webpage you want to clear the cache for, and go into Chrome Developer Tools. That's CMD+Option+I on a Mac, and CTRL+Shift+I or F12 on Windows, Linux, and Chromebooks. Click Empty Cache and Hard Reload in the list of options, and you're done.


1 Answers

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.

like image 169
Joe Avatar answered Sep 19 '22 21:09

Joe