HTML redirects being cached, randomly

CloudFlare says that HTML is not cached by default. It says a Page Rule is required.
I have no page rules.
The problem is that I have redirect code with country detection, and CF keeps caching redirects or non-redirects (where it should redirect, but doesn’t)
As soon as I put the site in Dev mode, or I purge the cache, then my redirects works perfectly.
Previous redirects were adding a meta-refresh tag into the HTML which was an obvious issue, however the new plugin I wrote, (WordPress), does a redirect in the header using wp_redirect, which is somehow being cached.

This is affecting my client’s business. I can’t seem to find a way to disabled it, particularly because it shouldn’t be happening, according to CF.

Any ideas?

Without knowing the domain name, we can’t check, but are you using APO with the Cloudflare plugin?

The domain is https://www.environskincare.com

If you access it from South Africa, for instance, with a VPN, it should redirect to /za but from USA it should remain.

I have the plugin installed, but it doesn’t appear to be connected. It’s asking me to sign in.
I had thought it was being used, but I guess I am mistaken - is there a way to check if there is a dead connection from the CF side?

You’re using APO, and it’s caching your pages. You’d have to disable APO if you want to do those redirects.

If you want to keep APO, you can use Transform and Page Rules to do this. There’s a YouTube tutorial for this:

1 Like

Thanks for the thorough response!
I’m not sure why it isn’t showing as connected to APO… So my concern is that if I disable the plugin, the settings will persist on CF? Can I switch it off from CF?
I’m happy to disable it, if CF will cache the rest of the content…

You might be able to disable it from the Speed → Optimization section of your domain at dash.cloudflare.com

Legend!

I checked there, and it was ticked, and I signed in on WordPress and disabled it there, and it reflected on CF.

Thanks for your help!

1 Like

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