Can I "Cache Everything" AND "Ignore Query String"?

Creating a page rule has “Cache Everything” and “Ignore Query String” in the same drop-down under the “Cache Level” option, but I want to do both.

Outside the page rules (Caching->Caching Level) there are 3 options, (No query string, Ignore query string, Standard) but the “Cache Everything” is mixed in when it comes to page rules.

I am caching the HTML content using a page rule with “Cache Everything”, but I want this cached page to be sent regardless of the query string.
I have set “Ignore query string” in the main settings which states the rule applies to static content but it looks like it ignores ‘static content’ when it’s created by a page rule.

The page rule looks like it ignores the “Ignore query string” in the main settings.

My results are:

Page rule with “Cache Everything” and pattern /*.html
I get a cache ‘HIT’ on the page but if I add a query string I never get cached content

Page rule with “Cache Everything” and pattern /*.html *
I get a “HIT” on the page and if I add a query string I get a ‘MISS’ then a ‘HIT’ on the next page load(s), however I get a ‘MISS’ again if I change the query string.
So the cache does work but the query string is not ignored but treated as different content.

Is there a combination / trick to let me cache the html and ignore the query string?
If not, these should be separate selections in the page rules, they seem unrelated.

  • Scott

Don’t think there’s a CF way to do this.

My origin server is set to serve some non-javascript content on a route that ends with .js and a “ignore query string” rule in place to achieve this, but that probably isn’t optimal.

A redirect page rule (or even on nginx/Apache) to redirect all query string to non-query string might also work.


Ignoring the query string for dynamic content can have obvious drawbacks. Since ignoring query string as far as Cloudflare caching is concerned will mean the same content is served no matter what query string is added to the URL, features like for instance a website internal search may stop working.

But if you know what you are doing and want to have the query string removed from the URL, you could create a Cloudflare redirect page rule, as @judge mentioned, to have it removed:

You’d need to test to find out whether the time added for the redirect compensates the time it takes to generate a new page out of your origin.

Also, you’d need to create other page rules and place them above the redirect, in order to exclude query-stringed static files that are already being cached under the “Ignore query string” setting, to avoid adding an unnecessary redirect for them.


There is if you’re an Enterprise customer and utilize a custom cache key, otherwise you’d need to implement your own caching strategy utilizing Cloudflare Workers.


Thank you for the replies.

I am only on Business and as the site still needs the query string (used by JS) I will leave it as-is for now, It was just a ‘fine-tune’ measure I can survive without until I upgrade.

  • Scott

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