Correct code for vary cookie in .htaccess?




Wordpress LScache Plugin: Correct code for vary cookie in .htaccess?

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi. I run a site with WooCommerce & WPML. I have 2 languages, Swedish default and English as secondary. I have WPML configured using separate URL:s for each language. So when accessing Swedish language visitors is on http://www.armsportbutiken.se and on English language visitors in on http://www.armsportstore.com, even though it is the same site. So I use currency converter widget that is only used for informational purposes, the customer always purchase with the Swedish currency SEK. But they can chose to view the prices in different currencies to estimate the cost in their local currency. I have been reading a lot about how to make sure the currency converter choice is only for the current visitor. And cookie vary seems to be the way to go. The cookie used by the currency converter is named: woocommerce_current_currency I have tested with adding this code to the .htaccess and have been running with this for a while: # BEGIN CUSTOM LSCACHE SETTINGS RewriteEngine on CacheLookup on RewriteRule . - [E=Cache-Control:no-autoflush] RewriteRule . - [E=Cache-Vary:woocommerce_current_currency] # END CUSTOM LSCACHE SETTINGS The reason that I ask about this is that I have noticed that sometimes when I browse the site from different browsers with/without VPN enabled just to check if everything works, sometimes I see the site in a currency I havent chosen myself. This makes me guess that I see the currency as someone else who visited the site have chosen that currency, which is what I want to get rid off. The code above is what I found in different forums/posts. But I also found an alternate rewrite rule: RewriteRule .? - [E=Cache-Vary:woocommerce_current_currency] And I dont understand the difference between using . or .? So to sum up my questions: 1. Which is the correct rewrite rule? The one with . or the one with .? 2. Is the full code above the correct code to insert to .htaccess to have vary on that cookie? 3. Where in the htaccess-file should this be placed? Does it matter where it is? So please respond like I am a child, as I have no clue what so ever about rewrite rules and .htaccess configuration. Hi, 1) both are correct in this context, . and .? both means match any and all URI 2/3) but better to put at top of your htaccess, not within LSCWP marker , otherwise it might get removed RewriteEngine On RewriteRule . - [E=Cache-Vary:woocommerce_current_currency] put these 2 lines at very top of your htaccess Best regards, Thanks @CacheCrawler for fast response. Okay, so all other rows of code in my example above is obsolete? Will try this and see if it works as intended Hi, yes , plugin will add these 2 CacheLookup on RewriteRule . - [E=Cache-Control:no-autoflush] so no need to double it Best regards, Thanks @CacheCrawler for the clarification. Appreciate the help. Hi. Sorry to re-open this thread. But have an additional question regarding this. I use WPML with two languages and the feature to use separate domains for each language. WPML sets a cookie for the language called wp-wpml_current_language should I add this to the vary to make sure both languages/domains are cached separately? And if so, what is the code to have vary on two cookies at the same time? Hi, last time I checked with WPML , as long as you have different URL for different language , like /en/page and /es/page , or /page?lang=en and /page?lang=es that kind of set , you should not need to have additional vary rule for WPML Best regards, Hi. Okay. In my case I use different domains. Swedish = http://www.armsportbutiken.se English = http://www.armsportstore.com It is accomplished by using the built-in feature in WPML for this in combination with setting up a domain pointer. So it is the same install and website, but different domains for each language (only use two). Is it the same for this situation? yes, as long as you dont have different content on SAME URL Okay, thanks



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference