Do I need separate cache folder for each site? How does the caching work?

#1
Hello,

I've installed OLS (v1.6.14) and CyberPanel.

I am trying to get my head around how the LS caching works.

I've managed to figure out that the cache files are stored in `/usr/local/lsws/cachedata/`. This folder is not writable to the hosts.

It appears all websites on the server store their cache files in that same one folder. Is that correct?

I am trying to understand how this works, because I would have thought each host/site should have its own cache folder, writable to the host, and that way when an application on that host (such as Wordpress, or in my case Craft CMS 3) needs to clear a page from the cache, it can. Or if the application needs to flush the entire cache, it can. Without affecting the cache of all the other sites on the server.

I have installed a LiteSpeed Cache plug-in on Craft. For it to work, it needs the path to the LSCache. Currently, when I change a page on the site, the server does not deliver the changed page, but continues to deliver the cached page. I know that's because Craft (and its plug-in) can't remove the cached page without the LSCache path. I can't use the `/usr/local/lsws/cachedata/` path, because the host has no access to it.

I should also mention that even when I put `RewriteRule .* - [E=Cache-Control:no-cache]` into the .htaccess file on the Craft site, the pages continue to cache. There seems to be no way to prevent caching from occurring. I can remove the entire rewrite rule section for LiteSpeed, and caching still occurs. I am not sure why that's the case.

The rewrite section I read in OLS doc to use for Craft CMS is:
```
########## Begin - Litespeed cache
<IfModule LiteSpeed>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{ORG_REQ_URI} !/admin
RewriteCond %{ORG_REQ_URI} !/index.php/admin
RewriteRule .* - [E=Cache-Control:max-age=86400]
</IfModule>
########## End - Litespeed cache
```

Would someone please explain what I am overlooking here or not understanding fully?

Thanks very much...

Jonathan
 
Last edited:

ltynk

New Member
#3
"each host/site should have its own cache folder " correct, you can set such cache root on virtual host level
Can you be please more specific about this? I have OLS and with and without CyberPanel and I don't see in Web Admin any option for the cache root. Also caching/purgin is working fine with the WP plugin for every site (no purging of other installs). What should be configured though? Thank you.
 

Pong

Administrator
#4
If no "storagepath" diretive, OLS will automatically create a folder named "cachedata" under /usr/local/lsws. If no virtual host level storage path, all domains cache will use server-level cache storage path. For share hosting, you can add cache module and set cache settings under each virtual host , especially "storagepath $VH_ROOT/lscache". You can check this KB for details.

https://openlitespeed.org/kb/openlitespeed-cache-module/
 

ltynk

New Member
#5
I found this, but it's strange because it seems that shared "cachedata" is working fine even with multiple WP sites. :unsure:
 
Last edited:

Pong

Administrator
#6
If only server level cache set up, it should be working fine. the limitation is the end user for the site may not be able to manage the cache such as purge cache manually since the end user doesn't have permission to the server cache root, other than that, all domain cache should be working fine for sure.
 

gilles

Active Member
#7
the limitation is the end user for the site may not be able to manage the cache such as purge cache manually since the end user doesn't have permission to the server cache root, other than that, all domain cache should be working fine for sure.
I'm taking an interest in this thread as I am on the other hand having issue with caching. I have publicly cached pages served to private sessions. I see the Cache-Vary rewrite rule properly set in .htaccess. I see the _lscache_vary cookie been set. Yet when I activate the cache, after some time, I run into this issue.

I have only setup the cache module at server level and the vhosts are running under their own user/group. I am not convinced this is the issue though as it runs fine at first. Only after some time (a few minutes to an hour), things go awry.
 

Pong

Administrator
#8
publicly cached pages served to private sessions is different topic and should be different thread. It has nothing to do with this cache root settings.
 
Top