Caching function

raphidae

Well-Known Member
#1
Hi,

I'm playing around with the caching function, and I was wondering if there is a way to set the maximum cache size (if reached the oldest files and/or files with the least hits are purged). Or is there a built-in limit?

The reason that I ask is that it seems that the server can just fill up the filesystem the cache directory is on. In my case I have a 512Mb ramdisk mounted for /tmp and the cache directory set to /tmp/lshttpd/cache.

Obviously I don't want /tmp to fill up, and creating a new ramdisk for lsws is not very efficient. A minimum percentage free on the filesystem setting would be perfect.

Also, I have some other questions:

1. I'd like to know what happens to the cache (files) in the event of;

-a graceful restart
-a shutdown and restart
-a crash

2. Is the original cached file checked for modifications between the moment it is cached and the moment it expires or are modifications only picked up after the cached file expires?

In any case it would be a nice feature to have the expiretime set dynamically based on hits etc. For instance to specify that a cached file expires after a day, but only if the file gets at least x hits/(timeframe<expiretime).

Thanks!
 

mistwang

LiteSpeed Staff
#2
Right now the cache module does not monitor the disk usage, user can clear up the cache directory regular with a cron job if needed. Should give enough disk space for it. We may add the feature to clean it up.

Cache file will stay on the disk until it was removed regardless lshttpd process status.

Right now, lshttpd only checks the expiration time which is part of header of each cache file, does not store number of hits there, only track it in memory, so if lshttpd restart, the hit counter will be reset. If store the hit count in the file, it will cause too many small random write which results in bad disk I/O performance. And it is difficult to keep it in sync among multiple lshttpd processes.
 
Top