Just installed Litespeed server and caching, running into caching issues.

#1
I noticed that after I switched from Apache + WP Super Cache to Litespeed + LSCache, that my front page over at www.theouterhaven.net, has been caching. This occurs on both desktop and mobile devices. A refresh fixes this, but if visitors see posts from days ago, it doesn't help me.

I've also noticed that caching seems to be hit and miss. The first time someone hits the site, the site is slow and doesn't load very well. Refresh a few times and it speeds up, until the next visit.

For the most part, I left the default values in place, with the exception of not caching the front page and for logins. Wasn't sure if the logins cache was helpful, but learned from other caching products that it wasn't helpful. I'm also noticing after looking at several threads that there's some benefit to changing the default values, but I'm not 100% on which. Right now I'm running on a VMware powered VPS with 4GB of ram, vcpu and the Litespeed 2CPU license.

I'll add that I am using CDNLinker so that the site points to the CDN I setup. The LSCache wordpress plugin doens't have this ability. I can also confirm that the website is being cached, yet it's slow when you goto the next page.


Server: LiteSpeed
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-LiteSpeed-Cache-Control: public,max-age=1800
X-LiteSpeed-Tag: B.1
X-Powered-By: PHP/5.4.45


I'm still new to Litespeed and as such I'm looking for any assistance that I can get.
 

NiteWave

Administrator
#2
Server: LiteSpeed
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-LiteSpeed-Cache-Control: public,max-age=1800
X-LiteSpeed-Tag: B.1
X-Powered-By: PHP/5.4.45
no "X-LiteSpeed-Cache: hit" in it, so this page is not cached.

if "X-LiteSpeed-Cache: hit" not seen in any page, then lscache is not set up correctly somewhere.

please try: add
<IfModule LiteSpeed>
CacheLookup public on
</IfModule>
in .htaccess in wordpress root, see if it'll fix it,
 
#3
I made the change. This is what it looks like in .htaccess.

<IfModule LiteSpeed>
RewriteEngine on
###LSCACHE START MOBILE VIEW###
RewriteCond %{HTTP_USER_AGENT} Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi [NC]
RewriteRule .* - [E=Cache-Control:vary=ismobile]
###LSCACHE END MOBILE VIEW###
###LSCACHE START RESOURCE###
RewriteRule wp-content/.*/(loader|fonts)\.php - [E=cache-control:max-age=3600]
###LSCACHE END RESOURCE###
###LSCACHE START FAVICON###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
###LSCACHE END FAVICON###
CacheLookup public on
</IfModule>

View inspection, it doesn't seem that it's hitting the cache still;

    1. Request URL:
      http://www.theouterhaven.net/2016/08/florence-machines-songs-final-fantasy-xv-available-now/
    2. Request Method:
      GET
    3. Status Code:

      200 OK
    4. Remote Address:
      76.12.157.15:80
  1. Response Headersview source
    1. Accept-Ranges:
      bytes
    2. Cache-Control:
      public, max-age=31536000
    3. Connection:
      close
    4. Content-Encoding:
      gzip
    5. Content-Type:
      text/html; charset=UTF-8
    6. Date:
      Sun, 14 Aug 2016 08:19:27 GMT
    7. Expires:
      Mon, 14 Aug 2017 08:19:27 GMT
    8. Link:
      <http://www.theouterhaven.net/wp-json/>; rel="https://api.w.org/"
    9. Server:
      LiteSpeed
    10. Transfer-Encoding:
      chunked
    11. Vary:
      Accept-Encoding
    12. X-LiteSpeed-Cache-Control:
      public,max-age=28800
    13. X-LiteSpeed-Tag:
      B.1
    14. X-Powered-By:
      PHP/5.4.45
 
#6
Hmm. I went ahead and removed the CDN Linker as all the hits were coming from keycdn.theouterhaven.net. Once I did this, I noticed that there were no hits coming from the actual server. It was all being hit from the CDN. That's disappointing. I setup the caching per the wiki and the plugin is enabled on the wordpress instance.

Not sure where to go from here, other than a complete uninstall / reinstall.

Regarding CDN's, should they be used in conjunction with Litespeed server + Lscache?
 
#7
OK, I believe I have it working now. I can see the X-cache miss / hit. CDN is still disabled as is Cloudflare, as I don't know if either were causing issues.

My own issue now is that even if I tell lscache to not cache the frontpage / homepage or tell it via .htaccess to only cache it for 10-20 seconds, it ignores it. I've tested this on several browsers, all pulled a different frontpage. One pulled it from 3 days ago!

This what my .htaccess rules looks like.

<IfModule LiteSpeed>
RewriteEngine on
###LSCACHE START MOBILE VIEW###
RewriteCond %{HTTP_USER_AGENT} Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi [NC]
RewriteRule .* - [E=Cache-Control:vary=ismobile]
###LSCACHE END MOBILE VIEW###
###LSCACHE START RESOURCE###
RewriteRule wp-content/.*/(loader|fonts)\.php - [E=cache-control:max-age=3600]
###LSCACHE END RESOURCE###
###LSCACHE START FAVICON###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
###LSCACHE END FAVICON###
###LSCACHE LOOKUPUP PUBLIC OFF###
CacheLookup public off
###LSCACHE END LOOKUPUP PUBLIC OFF###
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-login.php|wp-cron.php)
RewriteCond %{HTTP_COOKIE} !wordpress_logged_in_
RewriteRule ^$ - [E=Cache-Control:max-age=20,S=1]
# The homepage will be cached for 60 seconds.
RewriteRule .* - [E=Cache-Control:max-age=600]
# All other pages will be cached for 600 seconds.
</IfModule>
 
#8
Actually, I just saw an older post that had the same issue and you recommended changing the global cache expire time, so I changed it to there to 60 seconds.

I can see the site hitting the cache, cdn is still off, though I don't think it's going to cause issues if it is on.

curl -I http://www.theouterhaven.net
HTTP/1.1 200 OK
X-Powered-By: PHP/5.4.45
Cache-Control: public, max-age=31536000
Expires: Mon, 14 Aug 2017 10:54:57 GMT
Content-Type: text/html; charset=UTF-8
Link: <http://www.theouterhaven.net/wp-json/>; rel="https://api.w.org/"
X-LiteSpeed-Cache: hit
Date: Sun, 14 Aug 2016 10:55:23 GMT
Accept-Ranges: bytes
Server: LiteSpeed
Connection: Keep-Alive
 

NiteWave

Administrator
#9
if you install lscache for wordpress plugin, following rewrite rules should not be needed:
###LSCACHE END LOOKUPUP PUBLIC OFF###
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-login.php|wp-cron.php)
RewriteCond %{HTTP_COOKIE} !wordpress_logged_in_
RewriteRule ^$ - [E=Cache-Control:max-age=20,S=1]
# The homepage will be cached for 60 seconds.
RewriteRule .* - [E=Cache-Control:max-age=600]
# All other pages will be cached for 600 seconds.
and should keep
CacheLookup public on
in your .htaccess
 
#11
In the directions, it had me setup /home/lscache/. Is this being used even if it's not specified in the global? Also, I'm still seeing Lscache misses, which is puzzling. I thought it was configured correctly and the curl returns show it is hitting the cache.

And I still get the same issue with the homepage being cached. So when new stuff is posted, the site will not push it unless you refresh it several times.
 
#12
So far nothing has worked. New pages were not showing unless you did a hard refresh. I've disabled lscache from wordpress and will be removing it from the server.

Thanks for the help though.
 
#13
Sorry for the result. one of main targets is to make lscache and lscache wordpress plugin easy to use, but apparently failed on your case. in most cases it just works without problem.

if you provide ssh root access to the server, I'd take a look where the problem might be.

since we've been actively improving lsws, lscache and lscwp plugin, some wiki page / forum posts may be outdated or only apply for old version lsws. this may confuse some users.

if lscache for wordpress installed, the right guide is this wiki: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp
 
#15
Willing to try again. I've re-enabled the plugin and followed the directions from the link. Anything extra was removed.

As of now I can config that the site is hitting the cache;


Accept-Ranges: bytes
Cache-Control: public, max-age=31536000
Connection: close
Content-Encoding: gzip
Content-Length: 22536
Content-Type: text/html; charset=UTF-8
Date: Mon, 15 Aug 2016 01:35:33 GMT
Expires: Tue, 15 Aug 2017 01:35:25 GMT
Link: <http://www.theouterhaven.net/wp-json/>; rel="https://api.w.org/"
Server: LiteSpeed
Vary: Accept-Encoding
X-LiteSpeed-Cache: hit
X-Powered-By: PHP/5.4.45
 
#16
great!
And I still get the same issue with the homepage being cached. So when new stuff is posted, the site will not push it unless you refresh it several times.
please check if this issue still exist.

if there is a new post, homepage should update automatically (by default). you can configure it through the plugin:
LiteSpeed Cache Settings
Purge Rules
Front page: by default it's checked.
 
#17
It may still remain. I just posted a topic and I could not see it on my PC. I had a friend check out the site in their browser, Chrome, and it was there. It was not there in Edge, however. And now, when I check on Firefox, it is not there either. Wasn't until I hard refreshed.

I don't get it. Could it be that my browsers aren't clearing up cache or checking cache?

This is driving me crazy.
 

KevinFwu

Administrator
Staff member
#20
Hi,

Are you still running into issues? If there are things that need to be clarified, I'll try to correct it in the plugin for the next version.
 
Top