APO , UTM Query not by passes the cache

I used this utm for my marketing tracking (utm_source, utm_medium & utm_content), as it show in “Query parameters and cached responses Article” it said APO bypasses the cache and attempts to get a new version of the page from the origin by default. But the real result in my case, it’s not bypass so i need to turn off APO and it work fine, but if i turn on again the APO it will not bypass the UTM. what should i do?

Why would you need to bypass cache for pages with utm_ parameters?

APO will NOT bypass cache for these parameters, as normally these parameters are handled by JavaScript in the visitor’s browsers and therefore these pages benefit from caching. This is clearly indicated in the article you referred to. The general rule is to bypass cache for URLs with query strings, and that article lists several parameters that would reverse the rule.

APO serves cached content as long as the query parameters in the URL are one of the following:

  • ref
  • utm_…

But if you have a particular use case where you want them to bypass cache and force your origin to regenerate the page every time they are requested, you can create Cache Rules matching these URLs with the appropriate settings.

1 Like

actually my problem is like this, i activate the APO configuration for wordpress.

i’ve already activate the cache rule:
(http.request.uri.path contains “/konsultasi-sekarang”)
Cache status
Bypass cache

but it happens like there is no cache rule, here’s the capture

what i want is, if there’s visitor visit /konsultasi-sekarang?utm_campaign=test, in the form it will be filled automatically test.

but if i turn off the APO, it will work fine, but what i want is i still turn on the APO for others page but spesifically on this page /konsultasi-sekarang, i want bypass all cache so the form will be filled automatically test in utm_campaign field

sorry my english not that good, i hope you would understand what i mean.do you know how to solve this problem?

here’s the capture if i disable the cache and this is what i want

No problem. You can write in your local language (is that Indonesian?) and readers will be able to use the :globe_with_meridians: tool to automatically translate your text into English. You can also use that same tool to read what I’m writing here in your local language.

If I understood it well, you want to use APO on your website, but have some paths bypass cache, even when they have an utm_ query string parameter. Is that what you want?

yes, that’s correct.
do you how to do that? because i’ve tried with this cache rules

it still not working.

That’s strange. I have just created a similar rule on a test APO site and it worked after a few seconds.

Do you have other active Cache Rules? Or Page Rules?

Just tested a few times, and the result was cf-cache-status: BYPASS:

When I uncheck the Disable Cache on Dev Tools, I get a different response, but always with a MISS:

That means the origin is returning different responses each time. Check your origin cache, purge it and see if that results in what you want.

okay i just click purge everything on the cloudflare dashboard but still the reponse is MISS

if i only refesh (CMD+R) it always show MISS
but if i force refesh CMD+SHIFT+F5 = work well cf-cache-status: BYPASS

Due to your Cache Rule to bypass for the given URI Path, it was supposed to see MISS always for that path when Disable Cache is unchecked, and see BYPASS when the Disable Cache is checked.

In both cases, the response should come from the origin, not from Cloudflare cache. As I said, in a test APO site, a similar Cache Rule is working as expected.

What seems to be affecting your installation is that there’s a WordPress redirect that adds the trailing. slash to the path. Then somehow the trailing slash is removed. Do you have any rule or setting that would do that?

EDIT: first paragraph was edited.

i have confirmed in my WordPress that there are no rules/settings whatsoever adding the trailing slash to the path, and the trailing slash is removed.

Just like you said before, “Due to your Cache Rule to bypass for the given URI Path, it was supposed to see MISS always for that path when Disable Cache is unchecked, and see BYPASS when the Disable Cache is checked.” Is there any possibility to change this? because if the status is BYPASS, all the features work fine, whereas if the status is MISS, the function doesn’t work properly.

As an additional note regarding that form, I’m using the WPForms plugin and using the {query_var key=“utm_campaign”} method as per the information in [this link](https://wpforms.com/docs/how-to-use-query-strings-to-auto-fill-a-text-field/#Adding_a_Query_String_Variable_Smart_Tag). Is it possible that this could be the cause?"

Please see this:

As you can see above, the URL without the trailing slash was redirected to add the trailing slash.

You need to decide whether you want your canonical URL to be with or without the trailing slash. If the canonical is without the trailing slash, you should make sure to disable the WordPress feature that automatically redirects to the trailing slash. You need to check your Permalink structure and search online how to remove the automatic redirect.

Good. Now fix the Vary header. It should only return Accept-Encoding. It’s returning User-Agent which can cause all kinds of caching issues.


i sucessfully solve this problem by installing plugin Super Page Cache for Cloudflare and input the page exclude cache in this plugin.