htaccess file no cache

Written by
Date: 2013-01-27 15:10:13 00:00

Sometimes you want to avoid caching of your website, maybe you are developing it and you want to see the fresh copy each time you hit reload.

Provided that all caches in the path will obey these directives, this is the way you can do it.

I am also assuming you are using Apache and have access to .htacces file. Edit the .htacces file and add this lines:

<filesMatch ".(html|htm|js|css|jpg|png)$">
	FileETag 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 Jan 1975 05:00:00 GMT"

That is it. None of your pages or assest should be cached, you may want to add or delete some files' extensions in the first line.

Once your site is ready to the public you can add htaccess rules to cache the files