I have a WordPress client that we added a cache busting plugin, it works from time to time, but not 100% with everyone in their office.
They are now asking if I can put together a sample home page with cache busting in RW to see if this fixes it. They are continually asking how larger sites (Best Buy and Amazon (their examples) are handling this.
I have been using the RW “Generate Cache-Busting Links” in RW8, but every once in a while, a customer will tell me they are not seeing the latest updates. It happens for me on occasion as well with a website we update every week. It’s been much better since the RW “Generate Cache-Busting Links” was added to RW.
How do I ensure that cache-busting is 100%? Is that even possible? Is this tied to hosting at all @barchard? I know this particular client is using SiteGround with his WP site. I contacted SiteGround and they said with WP they use a server side cache that we have to empty out.
I figured before I sent out my RW example home page, I would make sure I covered all my bases and give them the most accurate information that I can.
If you want the browser to “re-read” the main pages you need to do this with changes to the HTTP header.
something like this in the htaccess file would work:
# BEGIN Caching
Header set Cache-Control "max-age=1, private, must-revalidate"
That would tell the browsers that a .html or .php files can only be cached for 1 second.
yes what @teefers said should help. you could try throwing a query string in the URL like ?no-cache=1 and see if that’ll get the browser to clear itself for them. This may help isolate the issue. Clearing the browser cache should also work.
Large companies use expiration policies so the asset is ‘short-lived’ (or long, depending on your application’s needs). That will force the browser to grab the latest copy from the server
This did not fix it. I went ahead and added to this site: https://costlessfoods.com/weekly-ad/. I change the ad every week and thought this would be a good place to test. Added the code to my htaccess file and nothing happened.
I then tried this in my head and nothing, still loads last weeks page for me.
meta http-equiv=“Cache-Control” content=“no-cache” />
meta http-equiv=“Pragma” content=“no-cache” />
meta http-equiv=“Expires” content=“0” />
Any other ideas? I’ve scoured through Google looking for something different to try.
The htaccess code I gave you above looks like it is being applied to the header and the Cache status is coming back EXPIRED. The HTML file is NOT being loaded from memory. Here is the http response from the URL above:
If what you change is not within this file (like CMS or JS), then you need to expire those files.
Make sure if you are using something like CloudFlare you refresh there as well.
I find it best practice to not rely on adding header data via HTML meta tags http-equiv, although it works it only gets applied to the HTML file, and if you have header data on the server (htaccess or other server config file) it will override the meta tags directives.
That’s why it’s being read from cache. You want jpegs to be cached, otherwise your site would become slow.
You might consider changing the file name every week. If that’s impractical then you could setup a cache directive for that single file.
That’s from the network area of either Safari’s web inspector, or Microsoft Edge developers tools (I don’t remember what one I used, all browsers have tools). It looks like Safari I’m not at a Mac right now, but under network you can display header data.
As for setting up a single file cache, I can give you the code, but I’m on my iPad and probably won’t be back to a desktop till Friday.
This is totally untested and should set the expiry to 3600 seconds(1 hour) for the single file. That’s if I’ve got the syntax right.
Header set Cache-Control "max-age= 3600, private, must-revalidate"
Try placing the code between the </filesMatch> and </ifModule> at the bottom of what i gave you above.