Help me understand cache behaviour (CF with WordPress)

Hey there,

I’m running several sites on cloudflare and am already doing this for a while. Historically different caches involved in the stack when using WordPress have always been a pain but this time I’m really having a hard time getting behind what’s going on here. I have already disabled server side caches to make sure there’s no problem here,.

I am using CFs Wordpress integration including the plugin. Things are connected and the cache refresh of pages that are being updates in WordPress seems to generally work fine.

BUT.

It seems like CF only delivers a change to the browser when this sends cache-control: no-cachewith the request. At least that’s what I found so far in chrome. I can use completely new chrome profiles, incognito windows and what not but I only get the right content after either hitting shift+refresh or disabling the cache in the developer tools. AFAIK there shouldn’t be any cache in new incognito sessions and also not in fresh guest profiles.

Interesting Safari 14 (macOS 11.1) shows a didfferent game where I seem to get the fresh content without forcing anything.

On a colleagues mac with Safari 14.0.1 (macOS 10) the problem is similar to Chrome on my computer except the problem that even shift+refresh doesn’t help there.

I’m really lost on how to tackle this issue as obviously I want to make sure my visitors get to see the latest content.

Response Headers from the old content clearly show the age

age: 240925
allow: GET, POST, HEAD, PURGE
cache-control: public, no-cache
cf-apo-via: cache
cf-cache-status: HIT
cf-edge-cache: cache,platform=wordpress

I’m thankful for any helpful in put on that issue. Not sure where to go next to find the issue.

cf-apo-via: cache

This means you have APO enabled. APO caches your Wordpress HTML content entirely and serves these pages from its own cache. When you change the HTML content, it should automatically purge cache and fetch the new copy from your origin web server.

The discrepancy you are seeing with cache-control: no-cache is caused by the fact that APO ignores requests with this header and passes them further down the stack, in this case to your origin.

If you are having issues with it, try disabling APO and purging cache. This should solve your problem, especially if you enabled it unintentionally.

2 Likes

Thanks @ncano

Sure, we do have APO enabled, but shouldn’t that exactly handle the issue by deleting the cache for the URLs involved in the content update? From what I understand this is what it does as CF delivers the right content to some browsers (but not to others).

I will try if swichting it off solves the issue, but then the feature is broken, right?

Also (sorry, it seems like I can’t edit my post) there seems to be an issue with purging the cache from the WordPress plugin. I just switch APO off, purged everything and waited a few minutes. I was still getting the old content from the cache. After purging the cache from the CF dashboard it seems to be working now.

I’ll monitor it in the coming days.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.