You can download mod_mem_cache patch for lighttpd 1.4.19 from here.
patching steps:
tar xfz lighttpd-1.4.19.tar.gz; cd lighttpd-1.4.19
wget http://blog.quehy.com/doc/lighttpd-1.4.19.mod_mem_cache.patch;
patch -p0 < lighttpd-1.4.19.mod_mem_cache.patch
sh autogen.sh
then run "./configure --quiet; make" to compile your lighttpd
mod_mem_cache got slightly update for lighttpd 1.5.0 r1811. detail documentation is here
download patch here
Jan suggested me to implement SLRU(Segmented LRU) for mod_mem_cache, full paper is here. SLRU is little complicated so we take simpler implementation:
"one LRU cache for the probationary segment, one for the protected
segment. On the first miss, an entry is added to the probationary LRU
cache, with no data. Only if its hit count increases over threshold it
is propagated to the protected LRU cache which has real content.
That way you decrease the propability that an entry is kicked out of the
LRU cache as you increase the threshold for one entry getting into the
cache."
new config: mem-cache.slru-thresold is introduced:
- By default mem-cache.slru-thresold is zero, SLRU just likes normal LRU.
- for mem-cache.slru-thresold > 0 when visit count for specific file in last 24 hours is bigger than mem-cache.slru-thresold, content of specific file is put into memory.
In practice, mem-cache.slru-thresold should adjust to archieve higher hit-rate and less memory usage.
Changelog:
- add implementation for SLRU
Upon Jan's kind suggestions, I cleanup mod_mem_cache source to conform lighttpd's coding style. configuration names are changed.
When mem-cache.expire-time=0, mod_mem_cache will compare etag of file with cached-etag, if no difference write cached content. This behaviour is different with previous mod_mem_cache version.
mod_mem_cache has following configuration:
- mem-cache.enable. enable or disable mem_cache, default to enable
- mem-cache.max-memory. maxium memory in Mbytes used by mod_memcache, default is 512(means 512M memory).
- mem-cache.max-file-size. maxium size in kbytes for single cache file, default is 512(means 512k bytes).
- mem-cache.lru-remove-count. number of cached items to remove when used memory reached maxmemory by LRU algorthim. default is 200.
- mem-cache.expire-time. cache's expire time in minutes. default is zero which means to check etag every time
- mem-cache.filetypes. content-type arrays which want to put into cache content. default is not set which means to cache all types. for examples: mem-cache.filetypes=("text/css") to cache css files only.
Changelog:
- configuration names changed
- use buffer as cache content instead void data