Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » Chameleon / ChameleonLite
- » Chameleon
- » Cloudflare GEO Redirect
Cloudflare GEO Redirect
Cloudflare GEO Redirect
I have a chameleon rule setup that redirects all new york visitors to a /new-york url. The redirect works fine, but whenever I enable Cloudflare the redirect stops working after a while and when I purge the Cloudflare cache it starts working again. So I guess somehow it is caching something incorrectly. Do you have any suggestions on how I can resolve this? Is there a way for me to prevent the caching of chameleon rule?
Thanks,
Sima
Re: Cloudflare GEO Redirect
Hi Sima,
Do you think this might apply to your situation:
https://support.cloudflare.com/hc/en-us … loudflare-
Perhaps in the Succeed Action where you do the redirect, you could use the PHP box to add an HTML header, perhaps like this: (I haven't tried this)
//set headers to NOT cache a page
header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1
header("Pragma: no-cache"); //HTTP 1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
Please let me know how you get on
Best regards
Stephen
Re: Cloudflare GEO Redirect
Just thinking about this some more, if for a certain URL, SOMETIMES it will redirect, and SOMETIMES it will show a particular page, then you need to ensure that Cloudflare doesn't cache the normal HTML page. Otherwise, all your New York users are likely to see the cached HTML rather than being redirected.
So, you might need to tell Cloudflare NEVER to cache that particular URL. Perhaps that's the home page? If so, you're going to have to choose what's more important: that Cloudflare caches the page, or that Chameleon gets the chance to check the GeoIP and do a redirect. Obviously, if the HTML of the page is cached at Cloudflare, then your server doesn't receive the page request at all, so Chameleon doesn't get a chance to test any conditions.
If you really want the best of both worlds, you could try to combine the 2 approaches by doing the redirect with some dynamic Javascript called from the page.
e.g. on your front page you could get it to load a JS script from your site e.g. mysite.com/myscript.js
Use Chameleon to detect the JS URL mysite.com/myscript.js, and if found and if GeoIP is from New York, then use a PHP script in the Succeed Action to add a redirect as well as adding the nocache headers.
In this way, the actual page can still be cached at Cloudflare, and the client will still call the little JS script from your server (not cached). And it's that script that does the redirect if necessary.
Hope that helps
Re: Cloudflare GEO Redirect
Hi Sima,
Joomla has a system of plugins that allow you to insert code into various stages of the system. Chameleon inserts itself pretty early in the process, before the exact page is processed, and allows you to make a number of changes to how the system works. Further internal plugins operate after the page is rendered, and allow Chameleon to make changes to the final output, based on conditions that are determined earlier in the process.
- Index
- » Chameleon / ChameleonLite
- » Chameleon
- » Cloudflare GEO Redirect
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5965
- Posts this week:
- 4
- User Info:
- Total Users:
- 8011
- Newest User:
- ignac84502
- Members Online:
- 0
- Guests Online:
- 145
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked