pideluxe Posted December 17, 2014 Share Posted December 17, 2014 What is you best practice for preventing web browsers from loading contents of newly generated or static sites from their cache, so that the visitor always gets the newest version? I tried the following, but not with the desired results: Meta-Tag "expires" with date in the past .htaccess-method described here (german) Any suggestions? Link to comment Share on other sites More sharing options...
pwired Posted December 17, 2014 Share Posted December 17, 2014 Try this: <?php header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> Or this with sunday as example: <meta http-equiv="expires" content="Sun, 01 Jan 2014 00:00:00 GMT"/> <meta http-equiv="pragma" content="no-cache" /> header('Expires: Sun, 01 Jan 2014 00:00:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache'); You can also do random Generated Numbers on the files you dont want to be cached. 3 Link to comment Share on other sites More sharing options...
isellsoap Posted December 18, 2014 Share Posted December 18, 2014 I think this Stack Overflow question + the answers is exactly what you need. In general, file versioning is definitely the way to go. It depends how your build process is though. Personally I use gulp with the gulp-rev package. There’s a pretty neat integration guide in the GitHub repo. 1 Link to comment Share on other sites More sharing options...
Recommended Posts