How to prevent those PHP variables from being cached on WordPress?

I’m using this code in functions.php on WordPress to generate an affiliate link based on the visitor location, It’s working perfectly but the problem is that if page caching is turned on (W3 Total Cache), The variables get cached so if someone from the UK was the first one to open the page then the second one from Germany opened the page he will get the same link that the first visitor got.

One more thing please, I’m still very new to PHP and javascript so I would appreciate if the answer was simplified enough

https://codepad.co/snippet/16geCgwA

Read more here:: How to prevent those PHP variables from being cached on WordPress?

Leave a Reply

Your email address will not be published. Required fields are marked *