Cf-cache-status is REVALIDATED when origin cache-control is no-cache

Hi Cloudflare experts, I need some help understanding this Cloudflare behavior.

I wish to cache some pages in our website so I setup a rule in Cloudflare that says

  • Cache-level = cache everything
  • Origin cache control [checked]

On the origin site, I have 2 versions of the page

  1. exampledotcom/page/?nocache=1 → I append nocache=1 when user is logged in to wordpress. Then cache-control is set to Cache-Control: no-cache, must-revalidate, max-age=0
  2. exampledotcom/page/ → This is the version I wish to cache in Cloudflare. Cache-control is set to public, max-age=86400

On the second case, the Cloudflare cache is working fine, I get HIT.

On the first case though, I only get EXPIRED (first visit) then REVALIDATED on the next visits. I am getting the Cloudflare cached page regardless of my changes to the page in origin.

Is there a way to exclude the first URL from caching through some rule sets or configuration in origin even though Cache-level is set to cache everything?

Thank you.



Solved by changing the default no-cache header to Cache-Control: no-store. This sets the Cloudflare response header to cf-cache-status: BYPASS for the ?nocache=1 version while still getting HIT for the cached version. But as a consequence, the browser will also not cache the no-store page but it’s a good enough tradeoff for me.

Purging the Cloudflare cache after you’ve changed your webserver’s Cache-Control header to no-store should solve the issue.