First things first I should say I spend my time to read all topics in this case but no success, recently I faced with a problem with client/browser cache on my website, It occurred without any change. Server side cache is good but client side working so bad, I should press CTRL+F5 everytime, I don't want this because it is bad for users, I know I can disable cache when devTool is open, but I'm talking about user not just myself. This happen on desktop and mobile device too. In mobile device I should go to setting/privacy/clear cache.
Here is my website codes relate to cache:
htaccess:mod_expires
ExpiresByType text/css "access plus 1 month"
I removed css
from gzip, but no success. Also changing 1 month to 1 second.
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
PHP header:
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Pragma: no-cache");
header("Vary: Accept-Encoding");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
HTML meta:
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
As you see I tried all possible way to fight with annoying cache but no success. I know I can add version
at the end of css
or js
but all know this is a bad habit to clear cache:
Remove query strings from static resources
Resources with a "?" in the URL are not cached by some proxy caching servers. Remove the query string and encode the parameters into the URL for the following resources:
So, what is the best to remove css
and js
heavy cache in the right direction?