For my site I have the following htaccess rules:
# BEGIN Gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>
# END Gzip
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES
I've just updated my site and it looked all screwy until I cleared my cache. How can I force the client's browser to clear the cache after an update so that the user can see the changes?
This worked for me.
look for this:
replace with this:
Upload and refresh page. You will get a page error.
just change it back to:
reupload and refresh page again.
I checked this on all of my devices and, it worked.
Change the name of the .CSS file Load the page and then change the file again in the original name it works for me.
The most straight forward is to add filetime to the request. eg
myfile.txt?2014-10-30-13:12:33
versioning by date.
You can tell the browser never cache your site by pasting following code in the header
And to prevent js, css cache, you could use tool to minify and obfuscate the scripts which should generate a random file name every time. That would force the browser to reload them from server too.
Hopefully, that helps.
Now the following wont help you with files that are already cached, but moving forward, you can use the following to easily force a request to get something new, without changing the actual filename.
Of course, the higher up in your folder structure you do this type of approach, the more you kick things out of cache with a simple change.
So for example, if you store the entire css and javascript of your site in one main folder
Then you can could start referencing it as "assets-XXX" in your html, and use a rule like so to kick all assets content out of cache.
Note that if you do go with this, after you have it working, change the 302 to a 301, and then caching will kick in. When it's a 302 it wont cache at the browser level because it's a temporary redirect. If you do it this way, then you could bump up the expiry default time to 30 days for all assets, since you can easily kick things out of cache by simply changing the folder name in the login page.