[Resolved] How LiteSpeed cache

Status
Not open for further replies.
#1
1) One of subdomain is used for storing static CSS and JS files. I notice the hit rate is always zero. Does LS cache static files? I understand caching static file does not help in improving the speed but I just want to know.

2) I used the following .htaccess file. Basically if the time is between 1900h and 2200h, the cache time is 180s. Otherwise, the cache time is 24hour. This does not work.
After 1900h, the pages stay the same. I remove all the time in the htaccess file and just use the fix TTL of 180s. Nothing change.
In the end, I have to delete all cache files to refresh the content in the pages.

Does LiteSpeed store the TTL in the cache file? Or LiteSpeed uses the cache file's date-time stamp?
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(png|txt|ico|gif|css|jpg|jpeg)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900
RewriteCond %{ORG_REQ_URI} !/admin
RewriteRule .* - [E=Cache-Control:max-age=86400,L]

RewriteCond %{TIME_HOUR}%{TIME_MIN} >2200
RewriteCond %{ORG_REQ_URI} !/admin
RewriteRule .* - [E=Cache-Control:max-age=86400,L]

RewriteCond %{TIME_HOUR}%{TIME_MIN} >1900
RewriteCond %{TIME_HOUR}%{TIME_MIN} <2200
RewriteCond %{ORG_REQ_URI} !/admin
RewriteRule .* - [E=Cache-Control:max-age=180,L]
Thanks in advance for any help.
 
Last edited by a moderator:

mistwang

LiteSpeed Staff
#2
For LSWS built-in page cache, it is a complete waste to cache static file in file system, then serve it from cache as static file instead of serving the original one.

The expire time of an cache entry is stored in the file for that entry. In your case, only when the previous cache entry has expired, a new entry will be created with new expire time, unless you explicitly purge the old entry.
 
#3
Understood why htaccess is not working as needed.
When the htaccess rules changes, LS continue to follow the expiry time in the cache entry and not the rules in the htaccess.
Thanks mistwang for the explanation.
 
Status
Not open for further replies.
Top