APO is not working correctly on my site

I’ve installed APO on my Wordpress page as per the the instructions, and via the plugin.

I’m trying to verify if its working and its showing as either Bypassing or Expired.
Cache has been purged a number of times so its definitely fresh.

I am using NitroPack for other optimisation. But they say NitroPack and APO work well together.

Anyone know what I’m doing wrong?

It changes from time to time.
Sometimes its
Cf-Apo-Via: origin,miss
Cf-Cache-Status: EXPIRED
Cf-Edge-Cache: cache,platform=wordpress

Sometimes its
Cf-Apo-Via: origin,cookie
Cf-Cache-Status: BYPASS
Cf-Edge-Cache: no-cache

APO is meant to cache static content HTML, and the presence of cookies tell it the content might not be static, even if it seems so to our eyes. You’re probably (I’m trying to guess here, it could be other cookies) running your tests with a logged-in browser tab.

image

Try visiting your site using your browser’s incognito mode. If you already did and the result is the same cf-apo-via: origin,cookie, you’d need to investigate what cookies your site sets for all visitors that may be causing this. See: Query parameters and cached responses · Cloudflare Automatic Platform Optimization docs

Also, make sure your visit your site with Dev Tools > Network tab > Disable cache unchecked. See: FAQs · Cloudflare Automatic Platform Optimization docs

Also:

NitroPack is also caching at the origin. And so is LiteSpeed.

image

See:

Nitropack specifically states it works with CF APO. I followed the instructions there and in CF’s Documenation.

Lightspeed Cache is probably a server side thing as I’ve not set it up myself so its happening somewhere else.

I looked at it through Firefox, and Chrome Incogneto and mostly they show “origin,miss” not cookie.

image

That means you’ve successfully removed one issue, and now you are seeing what visitors will.

Still, it’s another layer of caching that makes troubleshooting more difficult. Can’t you turn off Nitro’s caching and use only its optimization settings, and see how that goes?

Also, the fact that now you’re seeing cf-cache-status: EXPIRED as opposed to BYPASS means your page is supposed to be cached, but something keeps telling APO that there’s new content, when in fact there isn’t. So the cache keeps being invalidated. You need to investigate why your origin keeps updating the last-modified: header when apparently there’s no new content.

My Host is telling me that LiteSpeed is disabled for my site but when I check it its showing that X-Litespeed-Cache: hit and X-Turbo-Charged-By: LiteSpeed

Could Cloudflare be running LiteSpeed somewhere where I dont know about it?

Did you show this to your host, and they insist it isn’t running?

No. LiteSpeed is running at your origin.

Check your cPanel or equivalent admin panel to see if you see options to enable/disable/config it. APO can run well with LiteSpeed, but the option to cache based on device needs tinkering.

1 Like

I’ve just replied to my host with that info. Am waiting to hear back from them.

But yeah cPanel is showing that LiteSpeed is disabled.
So I’m really at a loss why the header is showing LiteSpeed is running

Have you checked your plugins to see if LiteSpeed in’t one of them? Some automatic installer may have added it.

LiteSpeed isnt a plugin by itself.
Unless its been bundled with another plugin that I’m not aware of.

But I’m not running anyother caching plugins.
Cloudflare (for APO)
NitroPack (for everything including caching)
RankMath (for SEO)
Smush Pro (for image optimisation)
Thrive Themes (as my my theme builder)
And a bunch of other plugins for various purposes

I might run through and deactivate the plugins to check if any of them is causing the issue

Yes, it is: LiteSpeed Cache – WordPress plugin | WordPress.org

I have it running on a few websites.

Sorry typo. I meant LiteSpeed isnt running as a plugin by itself.

I definitely dont have it installed as a plugin

1 Like

perhaps bundled with the theme?

Doesnt look like it.
Thrive Themes has Caching Plugins it recommends.
I dont believe they do any caching internally.

I did some more testing and discovered that there’s pretty much no rhyme or reason about when what cache gets triggered or skipped.

I created a screen recording about the situation here
https://nimb.ws/YD0hlP

And it shows that on a page refresh there are a number of caches that could get triggered or skipped.

NitroPack support said the following in response to me showing them the above video.

Hi Terry!

Thank you for the update!

I have reviewed the matter, and I can confirm the same behavior, however, I’m not fully sure if something could be done on our end.
I will try to explain our integration and what its main function is.

Basically, what we use the API integration for is to make sure that the Caches are in synch. However, this is ensured by syncronizing the cache purge/invalidations requests and that is it. Typically when the cache is refreshed at the same time that means that each new cache no matter its origin, it will contain all tthe fresh data. This is the mechanism that we use to synchronize the caches via our integration.

On our end we cannot confirm why exactly the CF APO cache is behaving like this. I believe the best shot here will be to consult with the support of that feature or Cloudflare and ask them if something has been done incorrectly on the configuration’s end or to check for misbehavior in their service! :slightly_smiling_face:
Kind regards,
Vasil D.
Technical Support at NitroPack

So right now I’ve got no idea who to speak to to get this resolved.

I’ll insist on this point:

Please notice in your video how the Last-Modified timestamp changes for the same page when you refresh. This is telling APO there’s new content, when apparently there isn’t.

So Nitropack support finally got back to me.
Their response is.

Hi Terry,

Our Developers have checked on the matter, and it seems that the issue is not related to NitroPack.

When NitroPack is disabled, on a first reload, it shows the proper headers; however, after a hard reload, the issue is present as well.
Video here: 'https://watch.screencastify.com/v/YeELhzxoyW34OIaJqkVR’

If the APO is disabled, but NitroPack is active, the Cloudflare headers are the correct ones.
Video here: ‘https://watch.screencastify.com/v/cXwRv2837tvyUavwqRlx’

Our Developers are advising us to check with Cloudflare why this is happening, and after the issue with the APO is resolved and there is something related to NitroPack, we can check again.
Kind regards,

So it seems that for some reason APO is causing the issue

I’m now getting

cf-cache-status: HIT
cf-apo-via: tcache

when I visit your site. So it seems to be working.

On the homepage it seems to be correct
But on ‘https://www.sparkleandshine.today/cleaning/house-cleaning/’
its EXPIRED and origin,miss

And several other pages, including for instance About Us, and Book Now.

You need to investigate what’s different with the pages that aren’t working that is making Cloudflare cache not possible for them.