• Resolved Maxen

    (@maxenmg)


    Hi! I have a question about Cache-Vary utilization.

    Basically, on current project there is a need to use Cache-Vary. As a result I added custom rule to .htaccess file:

    RewriteRule .? - [E=Cache-Vary:city]

    As you can see cookie “city” is used. Everything works great, but when I am enabling/disabling debug mode, .htaccess file is regenerated. As a result it leads to loosing this crucial configuration string.

    Question: is there a way to add this string back on enabling/disabling debug mode, or maybe even every time .htaccess gets regenerated?

    And second question: if Crawler is used to warmup caches, how I can setup page crawl with using certain “city” cookie value?

    • This topic was modified 1 year, 3 months ago by Maxen.
    • This topic was modified 1 year, 3 months ago by Maxen.
    • This topic was modified 1 year, 3 months ago by Maxen.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support qtwrk

    (@qtwrk)

    you need to add this OUTSIDE of LSCWP marker in your .htaccess file

    you can use cookie simulation in crawler setting.

    Thread Starter Maxen

    (@maxenmg)

    Putting this rule outside of its tag leads only to not working website, as all WordPress data in .htaccess is destroyed.

    More than that, as I read before, there was an instruction to use this string INSIDE this module.

    So putting LS specific rule outside of IfModule LiteSpeed tag ends bed.

    <IfModule LiteSpeed>
    RewriteEngine on
    CacheLookup on
    RewriteRule .* - [E=Cache-Control:no-autoflush]
    RewriteRule .? - [E=Cache-Vary:city]
    RewriteRule .litespeed_conf.dat - [F,L]
    Plugin Support qtwrk

    (@qtwrk)

    no , if you put it into of this block , it will be overridden when you save plugin’s setting

    please show me the full content of htaccess where it goes “bad”

    Thread Starter Maxen

    (@maxenmg)

    404 error on every website page sound’s not “bad” enough?

    “no , if you put it into of this block , it will be overridden when you save plugin’s setting” – yes, I know, that’s why I opened this topic, to get safe method of keeping this rule inside. And when this string is putted outside all wordpress rules get wiped on enabling / disabling debug mode.

    So the question is, where exactly this string should be put if there is no other option to ensure safe keeping this string into LS configuration?

    Plugin Support qtwrk

    (@qtwrk)

    yes, that’s why I asked you to show me the content of htaccess when it goes bad so I can review it

    I have bunch of sites and I just add additional directives like that

    Thread Starter Maxen

    (@maxenmg)

    Ok.

    Case #1. Rule added to WordPress section:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    RewriteRule .? - [E=Cache-Vary:city]
    </IfModule>
    
    # END WordPress

    Result – rule not applied.

    Case #2. Rule added to end of file:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    RewriteRule .? - [E=Cache-Vary:city]

    Result – rule not applied.

    Case #3. Rule putted right after LS closing comment:

    ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
    
    RewriteRule .? - [E=Cache-Vary:city]

    Result – rule applied, pages cached separately based on given cookie value, no 404 errors on pages.

    Thread Starter Maxen

    (@maxenmg)

    Right placement of custom rule – after closing LS comment:

    ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
    
    RewriteRule .? - [E=Cache-Vary:city]

    Result – rule applied, pages cached separately based on given cookie value, no 404 errors on pages.

    Plugin Support qtwrk

    (@qtwrk)

    These 2 no applies, because you put it at bottom, after a L flag, where L as Last, so any rule below will not be processed

    I an more wondering the 404 case, and please share me the full content of it

    you should place it before the first LSCWP marker, or after bottom marker but before WordPress rules

    Thread Starter Maxen

    (@maxenmg)

    “I an more wondering the 404 case, and please share me the full content of it” – I did not catсh same bug while testing on stage environment so I doubt it will help you at this stage.

    Thanks for your help, issue resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Cache Vary, custom rules in .htaccess and unsing Crawler with cache vary’ is closed to new replies.