A quick and easy way to prevent specific resources to be cached by sending the correct headers in .htaccess file.
For example, in the code below, we want that our htmls, js and css won’t be cached. This can be useful when you’re developing a site and want everything to refresh when you reload the page.
Those headers also come in useful when your site is behind a proxy, such as CloudFlare, and have little control on what gets cached and what not.
Put this code below in your .htaccess file (and of course change or add other files types)
1 2 3 4 5 6 7 8 9 |
<filesMatch "\.(html|htm|js|css)$"> FileETa None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 08 Feb 1984 08:00:00 GMT" </ifModule> </filesMatch> |