Wordpress LScache Plugin: IP2Locationm, AJAX Requests etc being cached ? Help with ESI
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hello, We have developed a large site that uses AJAX quite heavily to pull in web forms for the user and we are also using WPML. What we are finding is that say for example someone on the UK English site requests the enquiry form, they get returned the UK English string translations, which is fine. But if a German user on the German part of the site also requests that form, they get the form with the English string translations not the German ones. Its like the AJAX request has been cached. We also have problems with Geolocation, were using IP2Location and in PHP we query the local database for the location and then using a localised Javascript file insert this into a localised variable for us to use. But sadly it seems that whatever the site language was at the point the GeoIP Location was derived during the cache period, that response is what is always served up to the user regardless of actually where they are. We believe the solution to this is ESI, but I am a complete newbie at ESI and I wondered if someone could help either with this problem or point me in the direction of some documentation. I have tried implementing some code I found but it didnt work. As I say the issue isnt just with IP2Location, but also with AJAX requests in general. Many thanks. Hi @molokini, may I know does the AJAX contain any parameter to identify the language or it relies on users cookies? Also, could you please provide?your Report Number, found in?WP Admin > LiteSpeed Cache > Report and show us how to reproduce both issues? Hi @molokini , Based on what you described, yes it prolly will be cached and served wrong cache copy. Are your AJAX requests from REST? There is a Cache REST setting, if you turned it off, will it serve correct content for German users? Keeping non-cacheable is not an ideal solution obviously. But lets try that first for the first step. If true, you can consider to use vary to serve different cache for different users. If you are using AJAX to generate different contents, ESI may not help. Even it helps, Vary is still the main factor you will need to fix the issue. Hey guys, Thanks for your help. The AJAX requests are issued using a standard jQuery AJAX POST request to admin-ajax.php sorry for the slight vagueness on this but Im not an expert on all this! Essentially on the wp hook, were using IP2Location to look up the users IP in a database and storing that in a global variable called $IN_LOCATION. This is then put in a localised variable called IN_VARS which has a number of keys, but IN_VARS.in_location is the one that $IN_LOCATION goes in. Sorry if this all sounds bit obvious but I just need to explain what we have as this is an area of my knowledge that is not at expert level by any stretch of the imagination! I have set the Javascript file that this is localised into to not be cached but it seems IN_VARS always ends up with cached values, therefore the redirection suggestions end up wrong (as its the Javascript that manages the redirections and popups). Cookies arent used in this instance. The report reference is: ZEOOJTDB Hope that helps! Thanks. Could you please join our Slack channel or submit a ticket here for helping us to reproduce the issue? Thanks. Hi @molokini , I just checked your report number. From your page source code, I can see the IN_VARS js variable you mentioned. Yes as long as it is in source code, it will be cached. Is that IN_VARS manually written/customized by you or a certain plugin? IN_VARS does have a number of keys. But looks like it is not a mapping of location to URL. Can you state who makes the redirection? I noticed you have in_location_alt_url which is https://www. .net/us/ but when I visit the page, I wasnt redirected to www. .net/us/. The page kept me in www. .net. I can understand you are not an expert. That is ok. Lets try to fix it. No worry. Hello, Yes IN_VARS is only written to by our functions.php no third party plugins. The redirect doesnt occur because the code is disabled because it was giving all sorts of wrong dialogs suggesting the user is in Germany when they werent for example. Hope that helps and thanks for understanding my lack of expert knowledge! Thanks
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference