Exclude URL’s from APO optimization

I’ve searched the forum on this topic but couldn’t find an answer.
How can I exclude e.g. utm_medium from the APO cache?
I have dynamic content that changes quickly and I would like to exclude after utm_medium cache.
How can I do this? I will add that adding the variable: “(http.request.uri.query eq “utm_medium”)” to the cache rules does not help and there is still a cache.

Thanks for the help.

The query string will probably not be an equal match to “utm_medium”. Try using the operator “Contains”:

http.request.uri.query contains "utm_medium"

1 Like

I tried this but unfortunately, it doesn’t work.
Is there any way to make APO not cache when the utm_medium variable is in the URL?

You’re right. I’ve just tested this and it seems to only make cf-cache-status remain on MISS, but not to actually make it BYPASS, which is what you want.

An alternative would be to create a Transform Rule to add an extra parameter to the QS whenever the request contains utm_medium, if adding an extra parameter won’t mess things up down stream.

When requests match:
Query String contains "utm_medium"

Path: Preserve
QS: Rewrite to 
Dynamic: concat(http.request.uri.query, "&param")

For reasons only Cloudflare devs can explain, this will add “&param” twice, instead of just once. But that will make APO consider the request as a non-cacheable and therefore those requests will bypass Cloudflare cache.

Can anyone from cloudflare support comment? :slight_smile:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.