Page 1 of 1

Cache Busting

Posted: Sat Mar 27, 2021 1:47 pm
by Chris_t
Despite using external CSS files and having cache busting switched on, I find that users who have visited the changed pages previously (including myself) are finding the latest additions to a page all squashed up toward the top of the page overlayed on one another. An ordinary refresh does nothing but a hard page refresh does work. This doesn't seem to be able to be done on a mobile phone so the page continues to be displayed wrong.

Am I missing something about Cache Busting or are there situations where it doesn't work?

Re: Cache Busting

Posted: Sat Mar 27, 2021 2:10 pm
by Chris_t
apart from the obvious changes to the CSS file because of the changes to the page is there something to tell the browser that it should re-read the new CSS file rather than its cached version?

Re: Cache Busting

Posted: Sat Mar 27, 2021 3:41 pm
by BaconFries
Do you have a url to show what is wrong? You can add the following code using Page Properties and inserting into Meta Tags>Meta Tags>User Define

Code: Select all

<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

Re: Cache Busting

Posted: Sat Mar 27, 2021 4:49 pm
by Pablo
Cache busting only works for external CSS files.
For HTML and inline CSS you can use the meta tags as suggested by BaconFries

Re: Cache Busting

Posted: Sat Mar 27, 2021 5:01 pm
by Chris_t
Pablo: Thanks for your reply. As I said in my original post I am using external CSS files and the cache busting setting doesn't work for me.

Baconfries: Thanks for your reply. Giving you a URL won't be much help because you will not have visited the page before so the page will work OK. However, I think following on from what Pablo says I will abandon external CSS files and have internal CSS and use the code you posted.

Re: Cache Busting

Posted: Sat Mar 27, 2021 10:45 pm
by ColinM
Hi Chris,

As you say, cache tags inside the page may only work if the page is loaded for the first time with those Cache tags that BC advised on.

You could try and place a .htaccess file in the root directory of your website as follows:

Code: Select all

# DISABLE CACHING
<IfModule mod_headers.c>
	Header set Cache-Control "no-cache, no-store, must-revalidate"
	Header set Pragma "no-cache"
	Header set Expires 0
</IfModule>
I'd be interested to see if that works for you.

Re: Cache Busting

Posted: Sun Mar 28, 2021 6:59 pm
by Chris_t
Thanks Colin. As I mentioned in my reply I was going to try abandoning external CSS files and have the CSS embedded in the page and use BaconFries code to see if it worked. I am happy to say that it does seem to have solved the problem. Thanks BaconFries!

I will keep your suggestion on file as who knows, it might come in handy. :)

It's just a pity that the Cache Busting setting doesn't seem to work with external CSS files as it supposed to.

Re: Cache Busting

Posted: Sun Mar 28, 2021 9:32 pm
by ColinM
You're welcome Chris 8)