I’m currently working with Cloudafre, Autoptimize, and WP Rocket. I’m having some trouble on an actual page that is not displaying properly the page (https://lesdeuxpiedsdehors.com/asie/). A week or two ago, it was an other page.
If I examine the page, i do see i have a 404 on a Autoptimize script and i guess this is related. I can’t figure out where the problem is. I already know that if I decide to purge the CF cache of this page, it will be working fine again (I’ve tested it last time I had this trouble).
I’m not geeky enough to understand this and i’m looking for help or people who can have a look at the page. If someone have an idea, that would be great. I don’t know if the problem is from Cloudfare, Autoptimize or my set-up ?
That’s the danger of layered caching. Especially when you’re using Cache Everything in a Page Rule, as it appears you’re doing.
The caches have gone out of sync. Your Page HTML, which you’ve cached on Cloudflare has that autoptimize js hardcoded into it. But behind the scenes, Autoptimize has regenerated that js and given is a new serial number, then deleted the old one.
Now your cached main page has an outdated reference. You’ll have to turn off that Cache Everything Page Rule to stop that from happening.
Yes that’s exactly what i found too. Basically, the html page is cache on CF with the old autoptimize (AO) js and AO is behind the scene regenerating a new js so when the html is calling this file, it isn’t here.
What i don’t understand is it was working (i guess so) before. I’m not sure what changed ?
Is there a possibility that i can force the CF cache to be purged every time AO is regenerating a new css/js ?
I find it strange that it’s happening to you, but not me. In my case, I use Astra theme, which generates CSS in a similar way, and I had the same caching issue (Astra kept regenerating css and js), so I started using Autoptimize and that fixed the problem. I wish I new why Astra (and now AO) regenerates CSS and JS if nothing on the site has changed. I also wish they would let me turn off their cache-busting scheme.
For my Wordpress blog with Autoptimize with cache everything rules i have dynamic php pages with edge cache ttl = 1 day and css/js with edge cache ttl = 30 days so dynamic php generated HTML pages will always expire cf edge cache before css/js files will
Of course this depends on what and why your Autoptimize is regenerating the css/js concatenated files. It could be other wordpress caching plugins hooked into Autoptimize which when you purge those wordpress cache plugins, it also purges Autoptimize plugin cache too - forcing a regeneration of Autoptimize plugin’s cache and generated css/js files. I know Cache Enabler wordpress plugin does this if Autoptimize plugin is installed and detected too.
Thanks. I have no idea and why autoptimize is regenerating this file. I’m not sure why the AO cache is actually purging and how/where I can check this. Right now, I’m using WP rocket for page caching as well as Autoptimize.
I mainly use Autoptimize to optimize JS and CSS. The problem is, from time to time, I have tome 404 on some random page because my Html page on CF is calling a file that isn’t here anymore because it was regenerated by the purge of Autoptimize cache (if I understand correctly).
The question are:
Is this normal that autoptimize plugin is purging itself?
Would WP Rocket be responsible for this?
I’m not sure what to do anymore as this is random of course. I can’t always be sure, there’s a 404 from autoptimize somewhere and it’s only on 1/2 pages at the time
Knowing my luck, the HTML edge cache will expire and refresh five minutes before Autoptimize regenerates. Thanks for the Autoptimize filter suggestion. I’m looking forward to 2.7 that don’t break when it updates.
The most common triggers for full or partial cache deletion are:
On the Cache settings tab you can specify a Cache Lifespan. Only cache files older than the specified lifespan will be deleted. A cron job will run every hour to check which files should be deleted.
When you publish new content or update/edit existing content, the cache for that post/page as well as related content (e.g. taxonomy archives) will be cleared and (if your settings allow) preloaded.
So you want to purge CF cache when new post/updates are made and/or set WP Rocket cache lifetime longer than CF cache everything edge cache ttl
yes you add it to your functions.php file or you can create your own wordpress plugin for it. I did that to enable Autoptimize’s Gzip support which precompresses optimised css/js files with gzip and/or brotli compression for >3x performance https://github.com/centminmod/autoptimize-gzip
Thanks for the follow-up. I have no idea why but it seems that Autoptimize is listening to WP Rocket flushing the cache and clears its own in the same time. I tested it and it’s seems to be true as when i purges WP Rocket Cache, Autoptimize was cleared too. No idea though why.
Anyway, this was of course causing the problem in my humble opinion. So for now, i’ve installed WP Rocket no-cache add-on. This was, i think Autoptimize who purged itself. Maybe that’s a solution.
My only concern is about the “Autoptimize cache”. Won’t it grow bigger and bigger at time ? And if i understand, if i decided to manually purge the Autoptimze cache, i will also have to purge the couldfare cache. Otherwise, i will have the same problem again and again ?
PS : Yes i have asked the question directly at their support. Hope to get an answer
You should perhaps consider installing Cloudflare’s own plugin, and enable Automatic Cache Management, which will purge any page cache from its datacenters any time you edit or make changes to a page, and purge all pages when there’s a theme update or some other changes that affect all pages. It will also purge any Autoptimize cache related to those pages.
By calling the following hooks, the plugin will purge specific cache URLs:
autoptimize_action_cachepurged // for compatibility with the Autoptimize WordPress plugin
I’m not sure what are the main difference of these two options though?
For now, i have to figure out the interest of keeping WP Rocket with Autoptimize as all my optimisation are done in AO and i’m only using WP rocket for page caching as back-up when the CF cache is purged. but if i found a solution that i will be able to only purge specific URL’s automatically (WP cloudfare page cache or enable automatic cache management), i don’t see any interest of keeping WP Rocket, don’t you ?