View Full Version : Website cache

Aleksandar Apostolovski
May 30, 2019, 06:31 PM
Is there some way the website's cache to be reseted after some time?
For example if a mobile/pc user opens my website it gets stored in his cache, but if I do some visual changes I want my users to get the new version of the website.
How can I do that at my end?

May 31, 2019, 02:29 AM
In browsers exist some cache and this cache will be refreshed automatically.

Aleksandar Apostolovski
May 31, 2019, 02:36 AM
But when I do css changes the browsers keep the old version of the website

May 31, 2019, 02:42 AM
I have found this link in google: https://kb.iu.edu/d/ahic
Please read there about clearing browsers cache.

Aleksandar Apostolovski
May 31, 2019, 02:45 AM
I need solution for my users, not me.
How can my website force their cache?

May 31, 2019, 03:49 AM
Open ftp://.htaccess file
find lines:

<FilesMatch "\.(png|gif|jpg|jpeg|woff)$">
Header set Cache-Control "max-age=5356800, public, must-revalidate"

<FilesMatch "\.(css|js)$">
Header set Cache-Control "max-age=2678400, public, must-revalidate"

and replace to:

<FilesMatch "\.(png|gif|jpg|jpeg|woff)$">
Header set Cache-Control "max-age=1, public, must-revalidate"

<FilesMatch "\.(css|js)$">
Header set Cache-Control "max-age=1, public, must-revalidate"

save and check again. Also, after done of your changes with design in a few days return old code.

Aleksandar Apostolovski
May 31, 2019, 06:37 PM
Thank you Viktor. But when I test this from my mobile it still opens the website with some old cache. Any other solution? :/

June 1, 2019, 05:52 AM
Also you can add headers in php file. For example in index.php
try to add the following code:

header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
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");

Aleksandar Apostolovski
June 1, 2019, 11:18 PM
Still can't refresh some things. Would changing style.css to style1.css make my point? Where should I edit that?

June 3, 2019, 03:04 AM
Yes, you can try to rename the style.css file
Also, you need to change it in ftp://includes>>classes>>rlStatic.class.php
find method: addSystemFiles
and line:

$this->addHeaderCSS(RL_TPL_BASE . 'css/style.css');

Graham Jupp
October 24, 2019, 02:35 AM
I just wanted to add some experience I had with this issue today, a bit long winded but skip to last line if you get bored.

Yesterday I attempted to make some changes to a file, so I made a copy of it first and renamed the original file to a backup version.

I attempted to make some changes on the live version of the file which didn't end up working so I then deleted that file and renamed the backup version back to the original filename.

I then go to check my site today and notice that the edited version of the page is still appearing in the browser even though it doesn't exist anymore on the server.

So I try a CTRL + F5 refresh.. .still showing the non existent version of the page with the bad edits.... hmmm... I then switch to test the page in MS Edge which I hadn't previously used to test the page... still showing incorrect file... so this leads me to think its not a local cache issue.

So then I think, maybe if I rename the file to some other name and try to load the page, then it will refresh properly after it throws a file missing error. It didnt throw an error, but the section of the site was simply missing the section that the file relates to. I then rename it back to the correct name and the non existent incorrect file is still being cached.... arrrrghhh.

Then I wonder... hmm... what if it's an ISP cache issue and because the file has a "date modified" timestamp that is actually older than the edited version in it's cache... maybe the ISP cache is set up to always show the newer version of the file even if it no longer exists at the server.

Sooo... I make a small change to the file (adding an additional line break), save it, remove the line break, save it again.... then try in my browser again... Wahoooo.... finally it displays correct file, likely due to the fact that the modified date is now newer than the ISP's cache version.

Long story short, if the date modified on your file is older than the date modified on the ISP's cache of the file then I think this may be a possible cause of the issue with some ISPs.