Cookie Consent popup won't go away because its being cached

I have a Cookie Consent popup that should display just once per user.

Ideally when the visitor clicks the “Agree” button a cookie gets set that expires after one year. The popup is supposed to NOT appear to people who have that cookie. This works fine when the site is not being cached through Cloudflare.

But whenever the popup appears to someone the page they visited is cached and whenever anyone else visits that page they see the popup regardless of whether they have a cookie or not.

I have tried page rules that will only cache when the cookie is present but it doesn’t work. I can’t imagine why “bypass cache” for the cookie would help because then no page would ever get cached.

My page rules all use “cache everything” because it is the only way to cache the html and take the load off of the database. It is a very active News site.

I don’t understand why I haven’t seen anyone else with this problem.

I put the Cookie Consent popup on my dev site, so you can see this problem in action.

Can someone help me with this? What am I no understanding?


Bypass cache on cookie is for Business and Enterprise plans only. This helps is the cookie exists. In your case, you set a cookie when they click Agree.

Otherwise, the Cache Everything is a problem. I believe I have a site that uses Javascript for a cookie-based notification banner. It seems to do a good job of only showing up for people with a cookie. I’m not positive about this, but my recollection is I tested it and it worked.

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