Reputation:
If a page or even just a word on a page gets updated I won't see the changes until physically pressing the refresh button on the browser. Sometimes I'll even see versions that haven't existed for days. Note this isn't a SHIFT-F5 or a cache reset, it's literally just pressing the refresh button, f5 or on mobile swiping down to refresh the page.
I redirect all traffic to a routing index.php for basic mvc layout.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [QSA,L]
There is no PHP Opcache, there is nothing.
I have put this into .htaccess to make sure there is no caching.
<filesMatch "\.(html|htm)$">
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, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
Going to a different computer in the house, the site will again, show the old version until you press refresh on the browser. It's driving me crazy and I have no idea whats going on.
Note: This is a shared hostgator server.
Upvotes: 1
Views: 50
Reputation: 386
If you have cache problem with php file,you can use below code. It will remove your file from cache.
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");
If you are facing problem with any single css/js files, you can append the current date at end of url. So every time it loads from server not from cache
Example:
https://somewebiste.com/css/abcd.css?date=<?=date('ymdhis');?>
https://somewebiste.com/css/abcd.js?date=<?=date('ymdhis');?>
Upvotes: 1