Bypass Page Rule Failing with APO

I am using APO, which works great, except for one thing: I have pages that need to bypass the default APO caching (everything with the url construction /show/*/). I’m attempting to do this through a combination of setting a cache-header and defining a Cloudflare Page Rule.

Here is a page…

You will see this cache header:

max-age=3600, public

And here is my Page Rule in Cloudflare:

Based upon my understanding, Cloudflare should be purging that page after an hour. I have run several tests, and it’s not purging. I have a Cloudflare Pro account.

Here are the headers coming back in a curl:

content-type: text/html; charset=UTF-8
cf-ray: 85877c033f937cff-EWR
cf-cache-status: HIT
age: 43972
cache-control: public, max-age=3600
last-modified: Tue, 20 Feb 2024 02:23:55 GMT
link: <https://www.tvinsider.com/wp-json/>; rel="https://api.w.org/"
vary: Accept-Encoding, Accept-Encoding,Cookie
cf-apo-via: tcache
cf-edge-cache: cache,platform=wordpress
x-cache: HIT: 2
x-cache-group: normal
x-cacheable: SHORT
x-powered-by: WP Engine
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=sa%2B5hQrkiRjXXuXHq3l%2B0HXhkuOgoK%2FLq3GHAmGcOQMQTG%2FpqUzOoPQYMQaZTdspAsElJQiDzMHqQqjEPafnWrUE6KfSbtjEqA0SMa9VMeae9jVLB3TcIH%2F4XnGaZ%2Ft%2BfriQ"}],"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

Some things I notice in those headers:

  • cf-cache-status: HIT. It’s hitting Cloudflare.

  • cf-apo-via: tcache. It’s running through APO.

  • cache-control: public, max-age=3600. Cache is being set to 1 hour.

  • age: 43972. Cache is wildly surpassing the 1-hour limit. (You’ll see a higher number.)

I’m stymied. Cache will stay there for days unless I resort to the nuclear option — the “Purge Everything” button.

What am I doing wrong? Help is greatly appreciated. Thanks!

Hey there!

Cloudflare respects whichever value is higher: the Browser Cache TTL in Cloudflare or the max-age header.

Can you try adding a Browser TTL in that rule?

@Wanda Thanks for responding! I made that change and it does not seem to help.

First, per your instructions, I changed the Cloudflare page rule to also be an hour:

Then I then purged all caches in the system, and waited an hour…

Now let’s pick one of these pages… how about this one:

Here’s what my curl says:

date: Thu, 22 Feb 2024 23:08:31 GMT
content-type: text/html; charset=UTF-8
cf-ray: 859ae4385df88c2d-EWR
cf-cache-status: HIT
age: 4482
cache-control: public, max-age=3600
last-modified: Thu, 22 Feb 2024 21:09:09 GMT
link: <https://www.tvinsider.com/wp-json/>; rel="https://api.w.org/"
vary: Accept-Encoding
cf-apo-via: tcache
cf-edge-cache: cache,platform=wordpress
x-cache: MISS
x-cache-group: bot
x-cacheable: bot
x-powered-by: WP Engine
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=jD7hvsiaB7K8qfctK%2FjeX1NIJX%2BrOUif9mCQ%2Bmq9BEbdRM9%2BWASXwNXl9dvq2dc6R1FDnQauUHm3Yuyy9wyxBHLs7F49aZI9fH%2FnXTwgwB4Ro2DbnZY3GvxmYwFyR7rf%2BHL0"}],"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

As you can see, the age (age: 4482) is still exceeding the caching (cache-control: public, max-age=3600). If I just let that page sit there, cache will not puge for days, unless I manually purge it.

I feel like there’s something simple and obvious that I’m missing, but can’t figure out what. Thanks for your help!

Hi, this was solved by Cloudflare support by setting Edge Cache TTL Page Rule.

1 Like

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