Page Rules with dynamic tracking tags

I’d like to create a page rule that caches certain pages, however the problem is that these pages have some dynamic session tracking tags added to the url, eg;

example.com/?product=test&sessionid=1245

is there a way to cache the page without the session id?

example.com/?product=test

We can handle the sessionid on the client side, therefore I’d like Cloudflare to cache and retrieve the page by ignoring the session id everytime.

Note we have over 50,000 products we specify using querystring parameter.

Hi @robert18,

I guess you’re talking about the Ignore Query String cache mode:

Ignore Query String / Simple: Delivers the same resource to everyone independent of the query string (Note: The Ignore Query String setting only applies to static file extensions. This setting will remove the query string when generating the cache key, so that a request for “style.css?something” will be normalised to just “style.css” when serving from the cache.).


What are Cloudflare’s caching levels?

You can change the Caching Level option at the Caching tab from your Dashboard.

If you want to cache .html files, your Page Rule will need to set the cache level to Cache Everything for the required path.

Take a look at this support page to learn more about Cache Everything + Ignore Query Strings:

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

It sounds like you want to ignore certain query parameters, but keep others as they are essential. I don’t think this is possible even with a custom cache key.

Is it possible for you to move the sessionid to a hash fragment? As it’s not needed server side, why send it to the server? You have effectively added a cache busting parameter to the URI, and removing it will make life easier.

1 Like

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