Bypass Cache when ?ref=

Hi

My site is on WordPress and I set up a page rule to cache everything

On my home page, there is an option box the could get a parameter from the URL like this

I notice that because of the rule - visitors are served with cache HTML the contain the default ref or even a ref from another visitor - I recheck this with development mode

I set up a rule to bypass the cache when the ?ref parameter present on the URL

Also created another page https://www.morningdough.com/adw/?ref=xxxxx that works with a different form and set a rule to bypass the cache

But testing on my browsers - it seems that when I refresh that page I still get hit from the cache and the ref is incorrect

How can I solve this?

Thank you for your help!
Yakov

Solution

  1. Go to page rules

  2. Add below rule

I’m getting a BYPASS as the Cloudflare cache status for your link. Perhaps you are seeing the cached pages because they were cached by your browser, try incognito mode to check.

image

1 Like

Hi
Thank you for your help
But if I understand correctly - Ignore Query String means - serve the same page no matter is the parameter in the URL - and this is not what I am looking for

I fix the setting of the URL as you suggested but use Bypass - hope that this will work

tnx

1 Like

Hi
Thank you for your help

Yes, I disabled the Cache Everything until I find a solution

You have understood correctly.

Ignore Query String means do not vary cache based on each query string as unique key.

A Cloudflare user usually do it for fbclid, utm, ref and so on for high cache hit ratio.

in my case, I do need to get the “ref” parameter in my opt-in form - so serving the cache HTML without updating the code with the parameter it’s bad for me…

To avoid ?ref query string in the Analytics or opt-in form, you can set a Forwarding Page rule then

Assuming canonical is using https:// scheme and hostname is www.example.com

From https://www.example.com/*?ref*
To https://www.example.com/$1

if this is my URL - Morning Dough | A Free daily Online Marketing Newsletter
What will be the result of the Forwarding rule and how it help me?

tnx!!

https://www.morningdough.com/?ref=xxxxx

redirect to

:arrow_down_small:

https://www.morningdough.com/

like this… if it contains path, it will cover but without notorious ref query string.

Thank you for your help!

But. I am looking for the opposite

if the visitor arrives to https://www.morningdough.com/ - serve the HTML cache version

if the visitor arrives to Morning Dough | A Free daily Online Marketing Newsletter or Morning Dough | A Free daily Online Marketing Newsletter or Morning Dough | A Free daily Online Marketing Newsletter etc…
DON"T serve the cached version = BYPASS

Solution

This should be at #1 priority in the Page Rule List.

Just create a Page rule

https://www.morningdough.com/?ref=*

Cache Level: Bypass

#2nd Page Rule in order should be -

https://www.morningdough.com/*

Cache Level: Everything

Now, you have complete solution.

thanks

Cool
Thank you!!

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