Wordpress LScache Plugin: Developer question related to cookies
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hello, Im the developer of SrbTransLatin plugin (https://wordpress.org/plugins/srbtranslatin/). I use a cookie to serve two different versions of the same page (cookie: stl_script). One is in Cyrillic, one is in latin. Can I use vary_add somewhere in my code so LScache can cache two different versions of the page? In Cyrillic and in latin? The page I need help with: https://zool.dev/stl I am planning to add the vary cookie to setting, and give a new API in about v3.1 or v3.2. For now, please try the following codes and see if it works or not: add_filter( litespeed_vary_cookies, function( $cookies ) $cookies[] = stl_script return $cookies ) I have a similar situation. Im using a cookie to serve different versions of the same page. I tried your solution @hailite, but its not working correctly. The vary header is included, but only when cache is not hit: x-litespeed-cache: miss x-litespeed-vary: cookie=next_lan x-turbo-charged-by: LiteSpeed If the cache is hit, the vary header is nowhere to be found: x-litespeed-cache: hit x-turbo-charged-by: LiteSpeed Its almost acting like a passive dont cache certain cookies setting, meaning if for some reason the cache is not hit on some page (regardless of having the cookie), the x-litespeed-vary header will be included, but not otherwise. I get the same issue when using add_action(init, function() if (method_exists(LiteSpeed_Cache_API, vary_add)) LiteSpeed_Cache_API::vary_add(next_lan) ) Im also using Cloudflare, dont know if that affects cookies though. Hi, when you have cache hit , other header like x-litespeed-tag , x-litespeed-vary will be dropped and not shown to user. Could you please check on the content instead of header to verify if vary works or not ? Best regards, The content(a banner) didnt appear when the cache was hit, only when missed. I did get it to work by editing .htaccess though: ### marker LOGIN COOKIE start ### RewriteRule . - [E=Cache-Vary:wp-postpass_124e250c9dfea8eoe63758772526411e,next_lan ] ### marker LOGIN COOKIE end ### Now when I have the cookie set in my browser, the banner actually shows and cache hits as x-litespeed-cache: hit,private. I know this is not the best practice because its within ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##. How can I use it outside this block? Should I just include the following line: RewriteRule .? - [E=Cache-Vary:next_lan] outside the block by its own? Or maybe outside, but wrapped in tags? I dont know why the other methods didnt work for me, maybe the headers where overriden or had some conflict with another plugin. Hi, Please try move it out from LScache marker , I think it should still work Best regards,
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference