I’ve got in touch with WP Rocket and their response was;
Rosa from WP Rocket here. Thanks for contacting us!
I have checked your website
I can notice what you mention. This usually happens when the plugin uses PHP to do the geolocation and when WP Rocket is activated the cache system starts working, so, if the page is cached, the PHP will never be executed.
This is how caching works, avoiding PHP execution to reduce the loading time. This is the normal way WP Rocket (And other caching plugins) works.
Explaining a bit more, the PHP code will run only once (for the first visitor), and for the upcoming visitors will appear the cache version with the flag of the previous visitor.
To solve it, you can:
Using Geolocation/Geotargeting plugins with WP Rocket – poka’s geolocation plugin is not compatible with WP Rocket, but you can switch to a compatible one.
Disable page cache and keep optimizations globally on your site.
Disable the page cache feature in the affected pages.
Please keep in mind when you disable the cache feature, the performance of your website will be affected.
If your geolocation feature is using cookies then you might want to try the alternate method below:
Create Different Cache Files with Dynamic and Mandatory Cookies
Let me know if you need any further assistance, I am happy to help.😊
Best Regards,
I have disabled caching and it seems like GEO location is now shown correctly.