If you just want to strip certain query parameters, then use Transform Rules to strip the params you do not want. This can also be used to selectively remove query strings from certain assets (so you can target all .css files to remove all query strings).
I’m using query parameters add-to-cart, for example. I understand how I could use caching levels to achieve what I want, but I’m afraid that only works if you don’t use query parameters on your website. I can’t find that setting under page rules.
Also for example when you run Facebook Ads. They add a parameter fbclid that has a unique query string. That will stop Cloudflare from sending from it’s own cache.
I don’t know if I’m missing something, but assuming that on average costs half a second on a lot of websites, this is a million dollar problem.
Use a Cloudflare Page Rule to redirect any URLs which contain that kind of part
Use a Cloudflare Workers to try to achieve the same
Use a Cloudflare Transform URL - > Rewrite (in the background it’s working good, while the visitorURL in the Web browser sees the URL with the query strings)
There are few topics about it here, but I’d have to find them first using .
Thank you very much for your help. That was very helpful. I’ve not yet tried the transform rule idea, but I did set up a worker and it works as the developer toolbar shows cf-cache-status:HIT, even though I have a fbclid or utm-source attached.
However what I wonder is, will tracking still work the same way. I did try it, since I have first party tracking and even though I respond with the cached response the utm parameters were tracked. But I don’t know why. Shouldn’t they stop working if Cloudflare responds with the cached version?
In general, yes. If your Origin server is not varying its response based on the query parameter, then using the query parameter to shard the cache is just a waste of resources.
In general, these marketing parameters are picked up by client side javascript, and they work so long as the parameter still appears in the URL. If you redirect the request to one without the query parameter, then the client side tracking will not work.