Cf-cache-status: DYNAMIC : Why?

When I go to https://mydomain.com I get this every time. Shouldn’t it be HIT?

Here is my page rule:

https://mydomain.com/*

Browser Cache TTL: 2 hours, Cache Level: Ignore Query String, Edge Cache TTL: 4 days

I can’t for the life of me get my homepage to cache. But I have subpages that cache no issue.

I’ve tried removing the forward slash, but the Page Rule just puts it back by default.

Not sure what I’m missing.

All feedback appreciated.

Cheers
Ryan

Just want to do a follow up:

I added a page rule:

https://domain.com/

Browser Cache TTL: 2 hours, Cache Level: Cache Everything, Edge Cache TTL: 3 days

And everything worked great, I see it now return cf-cache-status: HIT

So, now that it is working, I changed it to:

https://domain.com/

Browser Cache TTL: 2 hours, Cache Level: Ignore Query String, Edge Cache TTL: 3 days

I get a lot of PPC traffic with “utm_source” so don’t want it having to reload entirely. Hence “Ignore Query String”. But this breaks the cache altogether, and I get DYNAMIC again while waiting for page to load.

What gives?

Maybe if you go to the regular “Caching” section of the dashboard and turn on “Ignore Query String,”, and then use the Page Rule for “Cache Everything”. Maybe that will give you the best of both worlds.

Ok, switched that Ignore Query String. How long does it take to kick in?

I changed the Rule to Cache Everything for home page.

So now:

https://mydomain.com
cf-cache-status: HIT

Awesome!

But…

https://mydomain.com/?utm_source=PPC
cf-cache-status: DYNAMIC

and if I attempt to refresh and load the exact same url again:

https://mydomain.com/?utm_source=PPC
cf-cache-status: DYNAMIC

So it won’t even cache the same url with parameters.

I’d just love to have my Home Page be cached, no matter what parameters come after.

Changes are effective immediately. Try loading that URL a bunch of times. Due to various randomness at the edge, it takes a few hits before you can get a HIT.

I get the feeling that the “Cache Level” in the Page Rule might override whatever you set in the general Cache settings. Maybe @cloonan knows.

1 Like

This is what I’m seeing:

https://domain.com/

Browser Cache TTL: 2 hours, Cache Level: Cache Everything, Edge Cache TTL: 3 days

The Miss then Hit work perfectly on home page.

https://domain.com/*

Browser Cache TTL: 2 hours, Cache Level: Cache Everything, Edge Cache TTL: 3 days

Miss and Hit work on home page.

But then it misses on, https://domain.com/?utm_source=PPC

That then is a HIT on second attempt. I’d like to HIT on first attempt, even when different parameter.

Then if I disable the rule and count on Ignore Query String, NOTHING gets cached:

https://mydomain.com
cf-cache-status: DYNAMIC

and will return that way over and over again. It refuses to cache. Isn’t the whole point of Ignore Query String to cache, even if parameters.

Cheers!
Ryan

There’s no way to have a HIT on the first request. :logo: is a pull CDN, so we have to go to the origin for content the first time. Unless you’re an Enterprise customer changing the default cache key ${header:origin}::${scheme}://${host_header}${uri} requires the use of a worker to set your own.

That’s correct. By default Cloudflare does not cache HTML as dynamic or frequently updated HTML content is commonplace.

A cache everything page rule is required to cache HTML.

2 Likes

Ahh okay. So the whole Cache page premise will only cache an actual page if “Cache Everything” is active.

There is no way to cache a page receiving different parameters as the same page then.

I didn’t realize the Ignore Query String only applied to images and CSS and not actual pages.

Cheers!
Ryan

There is. It either requires a custom cache key (Enterprise plan feature) or workers to set a custom cache key.

1 Like

This topic was automatically closed after 31 days. New replies are no longer allowed.