Title: Inline JS variable cached anyways
Last modified: September 5, 2024

---

# Inline JS variable cached anyways

 *  Resolved [Milan Bartalovics](https://wordpress.org/support/users/bmilanyco/)
 * (@bmilanyco)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/inline-js-variable-cached-anyways/)
 * Hello There!
 * I have difficulties to exclude an inline JS varable to be cached since it comes
   php.
 * `**_window_**.Yco.countryCode = '<?php echo $_SERVER['GEOIP_COUNTRY_CODE'] ??'';?
   >';`
 * I placed the string based exludes to all boxes [https://prnt.sc/3IO4iRzgpCNI](https://prnt.sc/3IO4iRzgpCNI)
   even added this to the inline script `data-no-optimize="1" data-no-defer="1"`,
   but I have no luck whit it. If I disable the plugin, then it works.
 * What do I do wrong?
 * Thank you!
    -  This topic was modified 1 year, 8 months ago by [Milan Bartalovics](https://wordpress.org/support/users/bmilanyco/).
    -  This topic was modified 1 year, 8 months ago by [Milan Bartalovics](https://wordpress.org/support/users/bmilanyco/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Finline-js-variable-cached-anyways%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/inline-js-variable-cached-anyways/#post-17996616)
 * the whole purpose of cache is to avoid php execution
 * so if you do it PHP way , as that `<?php echo` , it just won’t work , as it is
   not executed again.
 * you have 3 methods
    1. since you have GeoIP module already, you can enable GeoIP vary by add
 *     ```wp-block-code
       <IfModule LiteSpeed>  RewriteEngine on  RewriteRule .* - [E=Cache-Control:vary=%{ENV:GEOIP_COUNTRY_CODE}]</IfModule>
       ```
   
 * this will save cache based on country code
 * 2. use javascript or something to call admin-ajax.php to get the country code
 * 3. use ESI, wrap your output in ESI block, more detail: [https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url](https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url)
 *  Thread Starter [Milan Bartalovics](https://wordpress.org/support/users/bmilanyco/)
 * (@bmilanyco)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/inline-js-variable-cached-anyways/#post-17996791)
 * Thank you! The first sollution solved my issue.
 * You have a point. We just started using LiteSpeed and LSCache and I didn’t had
   problems with this before on wp-rocket / nginx.
   Thank you, have a nice day!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Inline JS variable cached anyways’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [exclude](https://wordpress.org/support/topic-tag/exclude/)

 * 2 replies
 * 2 participants
 * Last reply from: [Milan Bartalovics](https://wordpress.org/support/users/bmilanyco/)
 * Last activity: [1 year, 8 months ago](https://wordpress.org/support/topic/inline-js-variable-cached-anyways/#post-17996791)
 * Status: resolved