• Resolved Armsportstore.com

    (@armbreakersweden)


    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 https://www.armsportbutiken.se and on English language visitors in on https://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
    <IfModule LiteSpeed>
    RewriteEngine on
    CacheLookup on
    RewriteRule .* - [E=Cache-Control:no-autoflush]
    RewriteRule .* - [E=Cache-Vary:woocommerce_current_currency]
    </IfModule>
    # 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 haven’t 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 don’t 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.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support qtwrk

    (@qtwrk)

    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,

    • This reply was modified 3 years, 8 months ago by qtwrk.
    Thread Starter Armsportstore.com

    (@armbreakersweden)

    Thanks @qtwrk 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 ??

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    yes

    , plugin will add these 2

    
    CacheLookup on
    RewriteRule .* - [E=Cache-Control:no-autoflush]
    

    so no need to double it

    Best regards,

    Thread Starter Armsportstore.com

    (@armbreakersweden)

    Thanks @qtwrk for the clarification. Appreciate the help.

    Thread Starter Armsportstore.com

    (@armbreakersweden)

    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?

    Plugin Support qtwrk

    (@qtwrk)

    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,

    Thread Starter Armsportstore.com

    (@armbreakersweden)

    Hi.

    Okay. In my case I use different domains.

    Swedish = https://www.armsportbutiken.se
    English = https://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?

    Plugin Support qtwrk

    (@qtwrk)

    yes, as long as you don’t have different content on SAME URL

    Thread Starter Armsportstore.com

    (@armbreakersweden)

    Okay, thanks ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Correct code for vary cookie in .htaccess?’ is closed to new replies.