• Resolved hans410947

    (@hans410947)


    Hi,

    does LiteSpeed cache specific files for different countries?

    In my WooCommerce store I am using a plugin that sets the correct taxes depending on which country the visitor is from. But to make this plugin work with a caching plugin, the page cacheing plugin needs to be able to cache one copy of the websits′s content per country.

    So my question is if LiteSpeed can do this, and how to set it up?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 16 total)
  • Add this code on top of your .htaccess outside of LiteSpeed markers. This code generates different cache copy for each country and currency selection:

    <IfModule Litespeed>
    	RewriteRule .* - [E=cache-vary:wmc_current_currency]
    	RewriteRule .* - [E=cache-vary:woocommerce_tax_country]
    	RewriteRule .* - [E=cache-vary:wp-wpml_current_language]
     </IfModule>

    But note that built-in cache crawler does not know about these additional cache varies and therefore the cache cannot be warmed up.

    Thread Starter hans410947

    (@hans410947)

    Great, thank you so much!

    Is cache warm up the same thing as preloading?

    And if it is, do you mean that the main country cache can still be preloaded, but all other country-versions of the site will not be preloaded?

    Thanks!

    • This reply was modified 1 year, 8 months ago by hans410947.

    Preloading is preloading and cache warmup is cache warmup. This is something completely different, but I know what you mean. Whether the main language can be “preloaded” depends on whether a corresponding cookie is also set for the main language. If so, then you can save yourself the cache warmup via the built-in crawler, because then the respective cache copy is never used.

    Thread Starter hans410947

    (@hans410947)

    Thank you!

    Thread Starter hans410947

    (@hans410947)

    Hello again, can you please help me check if I added the code at the correct place?

    Thank you!

    <IfModule Litespeed>
    	RewriteRule .* - [E=cache-vary:wmc_current_currency]
    	RewriteRule .* - [E=cache-vary:woocommerce_tax_country]
    	RewriteRule .* - [E=cache-vary:wp-wpml_current_language]
     </IfModule>
    # BEGIN LSCACHE
    ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
    <IfModule LiteSpeed>
    RewriteEngine on
    CacheLookup on
    RewriteRule .* - [E=Cache-Control:no-autoflush]
    RewriteRule \.litespeed_conf\.dat - [F,L]
    
    ### marker CACHE RESOURCE start ###
    RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
    ### marker CACHE RESOURCE end ###
    
    ### marker FAVICON start ###
    RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
    ### marker FAVICON end ###
    
    ### marker DROPQS start ###
    CacheKeyModify -qs:fbclid
    CacheKeyModify -qs:gclid
    CacheKeyModify -qs:utm*
    CacheKeyModify -qs:_ga
    ### marker DROPQS end ###
    
    </IfModule>
    ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
    # END LSCACHE
    # BEGIN NON_LSCACHE
    ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
    ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
    # END NON_LSCACHE
    
    # BEGIN LiteSpeed noabort
    <IfModule rewrite_module>
    RewriteEngine On
    RewriteRule .* - [E=noabort:1]
    </IfModule>
    # END liteSpeed noabort

    Yes, it is correct. Well done. ??

    But you should restrict the noabort rule as it is too dangerous.

    Thread Starter hans410947

    (@hans410947)

    Thanks a lot for your help!

    What do you mean about the abort code?

    • This reply was modified 1 year, 7 months ago by hans410947.

    What do you mean about the abort code?

    Who set this rule?

    # BEGIN LiteSpeed noabort
    <IfModule rewrite_module>
    RewriteEngine On
    RewriteRule .* - [E=noabort:1]
    </IfModule>
    # END liteSpeed noabort
    Thread Starter hans410947

    (@hans410947)

    It was suggested by my security plugin Wordfence: https://www.wordfence.com/help/advanced/system-requirements/litespeed/

    This guy doesn’t know what he suggests. He offers a security tool, but creates new security gaps that he cannot close with Wordfence. To limit the risk, please let Wordfence give you the full path to the Wordfence script. After that, we set this rule correctly.

    Thread Starter hans410947

    (@hans410947)

    Thank you, I will send an email to Wordfence!

    Also, please tell him to remove this suggestion from his site.

    Thread Starter hans410947

    (@hans410947)

    Thank you, I will show them this thread.

    Thread Starter hans410947

    (@hans410947)

    Hello again,

    I asked the WordPress support to take a look at this thread and respond to it. This is their response:

    The code addition is not a security issue.

    Please see our guide below that explains the LiteSpeed External Application Abort feature:

    https://www.wordfence.com/help/advanced/system-requirements/litespeed/

    The LiteSpeed documentation also does not mention any security issue:

    https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:config:external_application_abort

    Of course, it is a security risk if you deny every PHP script the ability to interrupt it. Also, the noabort directive is the wrong directive for what this gentleman thinks he can fix with it.

    But it’s up to you. Do what you believe is right.

    FYI: The information on the LiteSpeed Wiki is out of date. This is the current information.
    https://docs.litespeedtech.com/lsws/cp/cpanel/long-run-script/

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Does LiteSpeed cache country specific files?’ is closed to new replies.