Wordpress - Not caching a bit of code

Mr_Parham

Well-Known Member
#1
Hi

We use PHP code to decide which ad should be displayed base on the user IP address, now the problem that I have is that I think when let's say a customer from country A open the website litespeed would cache that code and even though the php code says that the customer from country B need to see a different banner they still would see the banner for country A, is there anyway around this?

Ps - we have ads on every page of our website

Regards
Parham
 

KevinFwu

Administrator
Staff member
#2
Is it possible to use rewrite rules to set a GeoIP environment? You can set up to vary on the GeoIP environment, so that each IP is given the correct version. You are correct in what you think the problem is.

The set up would make it:

Country A -> rewrite (ENV=countryA) -> php (add ad for countryA) -> cached with ENV=countryA -> browser

Country B -> rewrite (ENV=countryB) -> php (add ad for countryB) -> cached with ENV=countryB -> browser

Here's the wiki article on this, let us know if you run into any issues setting it up!

Kevin

EDIT: If the ads are loaded in a wordpress widget, you could also try out our ESI version. It's currently in beta, but it allows you to 'no-cache' some widgets. https://github.com/litespeedtech/lscache_wp
 
Top