PDA

View Full Version : Website cache



Aleksandar Apostolovski
May 30, 2019, 06:31 PM
Hi,
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?

Viktor
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

Viktor
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?

Viktor
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>

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


and replace to:



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

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

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? :/

Viktor
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?

Viktor
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');