Cache and Geotargeting

By general rule page cache is NOT COMPATIBLE with geotargeting. By definition page cache is like a snapshot of all your dynamic content that it's saved into an HTML file.

That means that if you place for example a shortcode to display the user country and the first user that visits the page is from Argentina, the next user will see the cached page and will show also Argentina.

To avoid that you need to exclude that page from cache and that's how normally works in WordPress.

Cache with GeotargetingWP

On GeotargetingWP plugins we tackle page cache in different ways. The most important one is that we are compatible with a couple of cache plugins and also some hosting providers. Hosting with cache based on geolocation is the best way for using GeotargetingWP in your site.

WpRocket

WP Rocket: By default it creates a different cache version for each country.

WpRocket mode only works when AJAX mode is turned off.

If you need to create different cache pages for cities or states you will need to add some code in your site. You can extend this with filters for states or cities but be aware that enabling it will decrease performance in cache and more cached version of each page needs to be generated.

WpRocket uses cookies to handle this cache per country and because it's based on countries we recommend using it along with our local database plugin.

First load will be uncached until cookies and created for every user.

Extend cookies or disable them entirely

Wp Super Cache

Wp Super Cache: The plugin is managed by the company behind of WordPress and it's a really solid plugin. In order to use it with our plugins you need to use PHP legacy mode and enable late INIT option. That will have the page cache run after the plugin detects the user. (Not available in all hostings)

Ajax mode

The GeotargetingPro plugin have something called ajax mode that makes it compatible with any cache plugin. It will basically run an ajax call once the page it's loaded and update the content with simple javascript.

If you have any other cache plugin or hosting static cache such as varnish, this is the way to go, otherwise your users will see a cached version without their geolocation version.

Check out our WordPress geolocation solutions
to find out everything you can do!

Start your free trial