Bug? Cloudflare not caching HTML with query strings despite page rule

Test URL: https://cf-test.8mb.video/cf-test.php?stuff=7433525

Page rule:

I included the e-mail obfuscation bit just to make sure the page rule pattern is matching, and it is.

How to reproduce:

  • visit test URL
  • click the link to reload the page with new (different, unique) query string

Observed behavior:

  • The page reloads with a new random number (fetched the resource from the origin server)

Expected behavior:

  • The page reloads with the same random number, because the resource has been cached and not getting fetched over and over from the origin server

I have also tried changing “Cache Everything” to “Ignore query string” with same results.

And, yes, of course cf-test.php sends the appropriate headers (expires date far in future, pragma: cache, etc).

Even when visiting that URL without a query string, it’s not cached. I see it looks like you’ve set appropriate cache headers, but how about:

Can you try to add an Edge Cache TTL setting as well?

1 Like

Cache Everything is one Cloudflare cache level. Ignore Query String is another.

If you pick Cache Everything, your HTML will be cached (you can use Edge Cache TTL set as suggested by @sdayman to override origin cache-control settings if needed), but each query string will be treated as a different URL.

If you pick Ignore Query String, your static files (images, JS, CSS etc) with query strings (such as &ver=123, for example) will have the query string removed for cache purposes, but your HTML will not be cached.

EDIT: In order to mix them, you need either Enterprise Plan or Workers. If you do have an Enterprise Plan, you should use the cache key either in the same page rule that sets “cache everything” or in a worker, as explained here:

https://support.cloudflare.com/hc/en-us/articles/360023040812-Best-Practice-Caching-Everything-While-Ignoring-Query-Strings

I kind of thought that that’s what they were after. So it should still work for their use case.

1 Like

Why wouldn’t the HTML be cached under “Ignore Query String” – it’s a page rule. They said one could use page rules to cache HTML. Why would HTML be excluded from the “Ignore Query String” rule LOLOL?

OH, I get it - they introduced a bug on purpose to sell more Enterprise licenses.

Got it.

@cbrandt - I do thank you for your response, glad I only wasted 1/2 day on this. Really appreciate the reply.

Cloudflare has a right to earn money so I can’t complain too much, but this really feels like a bug that shouldn’t be there, or at best should be documented / more obvious / etc.

It also feels like it leaves the door open for someone to DOS attack. If someone wanted to hammer my site they could simply get the main page with different query parameters and overload the server. Caching HTML while ignoring query string would have prevented that.

1 Like

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