[OPENED AGAIN] Help needed to make cache work with pages other than the home page...

#1
Hi,
I have enabled litespeed cache from the admin panel.

When I add this to my wordpress htaccess file:

<IfModule LiteSpeed>
CacheEnable public /
RewriteRule ^$ - [L,E=cache-control:max-age=86400]
</IfModule>

With this, only the main home page shows the litespeed cache hit in the response header.

I just cannot get it to work with other pages on the wordpress site...

I tried with couple of different rewrite rules to include other pages, but either it doesn't work at all, or gives a 404 error on other pages.

Can someone from the tech dept give the correct code for including all pages except maybe wp-admin/wp-login, etc.

I have seen someone else also request the correct rewrite rules for wordpress sites, but somehow nobody has answered on his thread... kindly don't let this be another unsolved thread...

Thanks in advance...
 
#3
Hi,
Please find my htaccess attached (somehow I cant add it inline here)...

Code:
RewriteRule .* - [E=noabort:1]

   <IfModule LiteSpeed>
   CacheEnable public /
RewriteEngine On
RewriteRule ^$ - [E=cache-control:max-age=9600]

  </IfModule>



# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
<FilesMatch "\.(css|htc|less|js|js2|js3|js4|CSS|HTC|LESS|JS|JS2|JS3|JS4)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=3600, public"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|WOFF|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public"
    </IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC CDN
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|WOFF|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
   <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTPS} !=on
      RewriteRule .* - [E=CANONICAL:http://www.athleanx.org%{REQUEST_URI},NE]
      RewriteCond %{HTTPS} =on
      RewriteRule .* - [E=CANONICAL:https://www.athleanx.org%{REQUEST_URI},NE]
   </IfModule>
   <IfModule mod_headers.c>
      Header set Link "<%{CANONICAL}e>; rel=\"canonical\""
   </IfModule>
</FilesMatch>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# END W3TC CDN
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

My test site address: www.athleanx (dot) org

If you go to the above, you'll see the Cache: hit, but how do I get it to work with all other pages of the site?

My cache settings in litespeed admin are:
Storage Path /usr/local/lsws/mycache

Enable Cache No
Max Object Size Not Set
Cache Expire Time (seconds) 86400
Cache Stale Age (seconds) Not Set
Cache Request with Query String Yes
Cache Request with Cookie No
Cache Response with Cookie No
Ignore Request Cache-Control No
Ignore Response Cache-Control No
Enable Private Cache No
Private Cache Expire Time (seconds) Not Set
Do-Not-Cache URL Not Set


So kindly tell me what I need to do...
Thanks
 

NiteWave

Administrator
#6
the cache policy has problem.
change
Cache Request with Cookie No
Cache Response with Cookie No
Ignore Request Cache-Control No
Ignore Response Cache-Control No
to
Cache Request with Cookie Yes
Cache Response with Cookie Yes
Ignore Request Cache-Control Yes
Ignore Response Cache-Control Yes

you may see the difference.
for the rewrite rules:
CacheEnable public /
RewriteEngine On
RewriteRule ^.*$ - [E=cache-control:max-age=9600]

please try to change to
RewriteEngine On
RewriteCond %{REQUEST_URI} !/wp-
RewriteRule ^.*$ - [E=cache-control:max-age=9600]

if you need further help, please PM your server's login if it's ok with you.
 
#8
Hey experts,
Without any change at all, the same thing is happening.

cache:hit on the homepage and nothing on other pages...

Why is this happening, and especially without making any change to the server/htaccess...?
 
#10
I re-visited an article page. it returns 304

cache:hit not seen likely because wordpress cache plugin W3TC

litespeed only cache dynamic pages. it won't cache static page since it's not necessary at all.

if some article pages already generated to static file by W3TC, then static file is returned directly, without launch lsphp process, thus you won't see cache:hit in response header.

it's easy to have simple test to verify. add query string to an article URL, for exampe, ?a=1, then in 2nd access to the same URL, cache:hit is there.
 
#11
Ohhh, yeah I do have W3TC... but let me explain... I thought that litespeed cache COMPLETELY bypasses the need for running php? Whereas W3TC DOES have to run php to check if the page has changed/modified, right?

So are you saying that with either of them, the performance 'should' be the same?

And also, if you're saying that W3TC does not run lsphp once a page is cached (at least for that page), should I then disable litespeed cache completely?

(Ultimate aim is for a quick response from the server with a cached page.)
 
#12
for the first visit to a page, lsphp is launched.
then the result is saved by litespeed as cache AND saved by W3TC as static file (i.e., saved both times)

when 2nd visit come, the rewrite rule will rewrite to a static file which W3TC has generated, so litespeed think it's actually a static page (just like image / js / css ), and return the static file directly, bypass the php process

if the static file not exist, the rewrite rule will rewrite to index.php, which will launch a lsphp process. but just BEFORE launching php, litespeed check the cache. if the cache is there and not expired, cache is returned directly, bypass the php process too.

>So are you saying that with either of them, the performance 'should' be the same?
yes. both are static files like images, performance is same level, much faster (100 times ?) than dynamic page (which generated by php process)

for litespeed cache and W3TC, either is ok. not necessary enable both, in cache's point of view.
 
#13
Hi,
Please find my htaccess attached (somehow I cant add it inline here)...

Code:
RewriteRule .* - [E=noabort:1]

   <IfModule LiteSpeed>
   CacheEnable public /
RewriteEngine On
RewriteRule ^$ - [E=cache-control:max-age=9600]

  </IfModule>



# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
<FilesMatch "\.(css|htc|less|js|js2|js3|js4|CSS|HTC|LESS|JS|JS2|JS3|JS4)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=3600, public"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|WOFF|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public"
    </IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC CDN
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|WOFF|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
   <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTPS} !=on
      RewriteRule .* - [E=CANONICAL:http://www.athleanx.org%{REQUEST_URI},NE]
      RewriteCond %{HTTPS} =on
      RewriteRule .* - [E=CANONICAL:https://www.athleanx.org%{REQUEST_URI},NE]
   </IfModule>
   <IfModule mod_headers.c>
      Header set Link "<%{CANONICAL}e>; rel=\"canonical\""
   </IfModule>
</FilesMatch>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# END W3TC CDN
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

My test site address: www.athleanx (dot) org

If you go to the above, you'll see the Cache: hit, but how do I get it to work with all other pages of the site?

My cache settings in litespeed admin are:
Storage Path /usr/local/lsws/mycache

Enable Cache No
Max Object Size Not Set
Cache Expire Time (seconds) 86400
Cache Stale Age (seconds) Not Set
Cache Request with Query String Yes
Cache Request with Cookie No
Cache Response with Cookie No
Ignore Request Cache-Control No
Ignore Response Cache-Control No
Enable Private Cache No
Private Cache Expire Time (seconds) Not Set
Do-Not-Cache URL Not Set


So kindly tell me what I need to do...
Thanks
It's working VPS license or not? I recently purchase 2GB VPS + Cpanel + VPS Litespeed.
But this is not working on webserver information what i have to do please reply or PM me thanks!
 
#15
please refer this page:
https://store.litespeedtech.com/store/cart.php?gid=2

for VPS license, LSCache is optional, click "Order Now", you'll see its price is $6 USD
I purchase LSCache for 3 cpanel i want to setup it now.
How to setup a LSCache to my wordpress website?
I need this type of setup.
Web server LiteSpeed

HTTP response code 200
Server Address
accept-ranges bytes
cache-control public,public, max-age=2112
connection close
content-encoding gzip
content-length 12057
content-type text/html; charset=UTF-8
date Sat, 01 Aug 2015 13:40:24 GMT
etag "2f19-55bcc678-d4f1d649f97873eb"
expires Sat, 01 Aug 2015 14:15:36 GMT
last-modified Sat, 01 Aug 2015 13:15:36 GMT
pragma public
server LiteSpeed
vary Accept-Encoding,Accept-Encoding, Cookie
Time to contact web server 0.450018 seconds

Can you help me out?
 
Top