APO cached pages not being auto-refreshed after expiry

Hello everyone.

I’ve been trying to figure out how to get APO to refresh its caches automatically without an API or a manual purge by URL. I’ve been through documentation, the forums, and whatnot and have not found any way to make it refresh “on time”.

Have I misunderstood what triggers cache clearing? Does it always need to come as a request from the WordPress plugin via API?

Current settings on Cloudflare:

  • Plan: Free
  • Caching level: Standard
  • Browser Cache TTL: Respect existing headers
  • APO: Enabled (Cache by device type: Disabled)

Below are a few examples of cURL requests trying various scenarios and header combinations at the origin.

Example 1

No max-age or s-max-age instructions are sent, only last-modified and expires. The date response header has passed the indicated expires time and yet APO has not refreshed the cache.

curl -sv -o /dev/null https://theatrum.ro/program-teatru-bucuresti/ -H 'Accept: text/html'

> GET /program-teatru-bucuresti/ HTTP/2
> Host: theatrum.ro
> user-agent: curl/7.79.1
> accept: text/html
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200
< date: Wed, 27 Apr 2022 13:10:33 GMT
< content-type: text/html; charset=UTF-8
< cf-ray: 7027cc885fb16d7d-MUC
< age: 408
< cache-control: public, no-cache, must-revalidate
< expires: Wed, 27 Apr 2022 13:06:44 GMT
< last-modified: Wed, 27 Apr 2022 13:03:44 GMT
< link: <https://theatrum.ro/?p=4076819>; rel=shortlink
< vary: Accept-Encoding
< cf-cache-status: HIT
< cf-apo-via: tcache
< cf-edge-cache: cache,platform=wordpress
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< x-turbo-charged-by: LiteSpeed
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=lzoGGR56mujm7d1nU4CCo79O3EYO%2BZyQU2Wc24daqexxUlGsAgPzyMuOWHo1OS%2F5csquzc%2BlFZqib3KJJmYmtl8XK7B%2BdoTnRx0UJCKVDrrqa4T9dRxD7Up5TCiYtg%3D%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

Example 2

max-age of 12 hours yet the content served is almost 3 days old. Expires likewise didn’t help.

* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200
< date: Tue, 26 Apr 2022 16:21:58 GMT
< content-type: text/html; charset=UTF-8
< cf-ray: 7020a7896e2768f2-FRA
< age: 250658
< cache-control: public, max-age=43200, stale-while-revalidate=3600, stale-if-error=43200
< expires: Sun, 24 Apr 2022 00:00:00 GMT
< last-modified: Sat, 23 Apr 2022 00:00:00 GMT
< link: <https://theatrum.ro/?p=3711393>; rel=shortlink
< vary: Accept-Encoding
< cf-cache-status: HIT
< cf-apo-via: tcache
< cf-edge-cache: cache,platform=wordpress
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< x-turbo-charged-by: LiteSpeed
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=iwtYSSWnahHnGYq58CTU3T5koeGJZ9qQOe3IZapLQDGZhDDKdXaXPeZzSQ%2B1ePkvYzD1Yme9xMWTbcep1lN9N%2Bgi%2FWjxeCi%2FmZWv3pSSlQssdOfxfS%2F4%2BdM42Ewpcw%3D%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

Example 3

Same URL as Example 2 above, max-age of 12 hours yet the content served is almost 5 days old. Requests behind Examples 2 and 3 have been run within a minute of each other for the exact same URL, from the same source IP, reached the same CF datacenter. What’s going on, why do I get a response varying between 3 and 5 days old?

* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!

< HTTP/2 200
< date: Tue, 26 Apr 2022 16:22:08 GMT
< content-type: text/html; charset=UTF-8
< cf-ray: 7020a7aa7ec39ba1-FRA
< age: 401351
< cache-control: public, max-age=43200, stale-while-revalidate=3600, stale-if-error=43200
< expires: Thu, 21 Apr 2022 00:00:00 GMT
< last-modified: Wed, 20 Apr 2022 00:00:00 GMT
< link: <https://theatrum.ro/?p=3711393>; rel=shortlink
< vary: Accept-Encoding
< cf-cache-status: HIT
< cf-apo-via: tcache
< cf-edge-cache: cache,platform=wordpress
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< x-turbo-charged-by: LiteSpeed
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=MUKOmHoE9Tm73Fj7Q8OZ%2FQNJT5a2mAMPviDHeHffBrTNePf1azdV2lp0fpc%2FkvTVR7bsUbVWUFJl6CTFyoyZPWr7ObKxSWU4cusLTQWpRFWJ3aLbNAzREbgL64Z3zQ%3D%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

Thanks in advance for your support.

Quick update:

In the meantime, I’ve disabled APO for this site and have enabled a Cache Everything page rule. Here’s what I found as differences in behavior:

  1. APO does not clear caches unless instructed by the WordPress Cloudflare plugin via API or a manual cache clear through the CF Dashboard. APO seems to be a PUSH-type cache based on Workers KV, which does make a lot of sense for highly geographically-distributed traffic around the world, but not as much for traffic that’s concentrated in a smaller country getting served by only a couple of CF Edges.

  2. Cache Everything is a PULL-type cache that does have auto-refresh at play. Once a URL has passed the max-age/expiration time the cache status goes from HIT to EXPIRED and then back to HIT, and this is stateful for every Edge, as they don’t share data.

I’m curious whether my testing/understanding is accurate, so please let me know your thoughts.

We are facing exact same issue when APO is always serving content from the cache inspite of adding or updating content.

On home page or landing page content are dynamically updated but rest of the pages are always served from cache even after adding and updating any post. We have also raised ticket but not got any solution so far.

If we will stop APO then site is working back to normal but speed getting degraded. We wanted to use APO but at the same time fixing above issues.

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