Project

General

Profile

Docs ModCache » History » Revision 27

Revision 26 (akrus, 2008-12-31 09:23) → Revision 27/32 (simmel, 2009-03-09 09:22)

h1. Web Accelerating Cache 
 
 *Module: mod_cache* 

 {{>toc}} 

 h2. Description 

 mod_cache site comes back again since feb. 29, 2008 
 mod_cache provides a shared web cache for mod_proxy and uses a configuration similar to Squid Cache.    mod_cache has several key benefits: 

   * Simple: mod_cache sets lighttpd flags between request handling stages. The request is then handled by mod_staticfile, mod_proxy, or other modules. 
   * Robust: mod_cache stores caches to the filesystem rather than to memory in order to avoid memory leaks/exhaustion. 
   * Fast: Lighttpd uses the Sendfile system call, which writes the file to the network interface directly. 
   * Powerful: mod_cache can be used in conjunction with other lighttpd plugins (except mod_deflate and mod_secdownload).    For example; using mod_compress to compress cached files, using mod_access/mod_trigger_b4_dl to implement anti-hot-link restrictions, or using mod_flv_streaming to do native flv file streaming. 

 With the shared web cache, mod_proxy is able to deliver content from the local cache without having to re-download bulky files, thus simultaneously increasing the speed from the    user's perspective while reducing bandwidth up-stream of the server. 

 This is not intended to be a reverse-proxy as one is rarely useful with Lightttpd, as Lighttpd is designed to handle a large number of concurrent requests with minimal resource usage by loading external applications (eg. FastCGI) only when needed, gracefully handling slow user transfers without blocking, and as of Lighttpd 1.5, performing asynchronous file operations.    For more information on optimizing the performance of Lighttpd, see: http://trac.lighttpd.net/trac/wiki/Docs:Performance 

 h2. Installation 

 This module is a 3rd party module and is not included in the official distribution. You can download the patch from here: 

 * For lighttpd 1.4.13: http://www.linux.com.cn/modcache/lighttpd-1.4.13.mod_cache.v1.2.patch 
 * For lighttpd 1.4.18: http://www.linux.com.cn/modcache/lighttpd-1.4.18.modcache.v.1.4.3.patch 
 * For lighttpd 1.4.19: http://www.linux.com.cn/modcache/lighttpd-1.4.19.modcache.v.1.6.0.patch 
 * For lighttpd 1.5.0.r1605: http://www.linux.com.cn/modcache/lighttpd-1.5.0.r1605.modcache.v.1.3.2.patch 
 * For lighttpd 1.5.0.r1992: http://www.linux.com.cn/modcache/lighttpd-1.5.0.r1992.modcache.v.1.4.2.patch 
 * For lighttpd 1.5.0.r2294: http://www.linux.com.cn/modcache/lighttpd-1.5.0.r2294.modcache.v.1.6.1.patch 

 or you can download the following patched versions of lighttpd: 

 * 1.4.19: http://www.linux.com.cn/modcache/lighttpd-1.4.19.modcache.v.1.6.0.tar.gz 
 * 1.5.0r2294: http://www.linux.com.cn/modcache/lighttpd-1.5.0.r2294.modcache.v.1.6.1.tar.gz 

 The PCRE library is needed to build mod_cache. 

 Always check for updates before attemping to install this or any other 3rd party module. 

 If the official source is not available there is a google group dedicated to mod_cache: http://groups.google.com/group/mod_cache 

 h2. Options 

 See [http://www.linux.com.cn/modcache/] 

 *cache.bases* 
 directory arrays which want to save cache files. 

 e.g.: 
 cache.bases=("/data/cache", "/data2/cache") 

    Default: not set 

 *cache.enable* 
 enable or disable mod_cache. 

 e.g.: 
 <pre> 
     cache.enable = "disable" 
     $HTTP["host"] $HTTP[[host]] == "video.example.org" { 
       cache.enable = "enable" 
     } 
 </pre> 

    Default: enable 

 *cache.domains* 
 domain pcre regex arrays which mod_cache will cache. 

 e.g.: 
 cache.domains = ("mydomain.com$") 

    Default: not set (all domains are cached) 

 *cache.support-queries* 
 ignore '?' in request url or not. 

 e.g.: 
 cache.support-queries = "enable" # mod_cache treats "/uri?q1" or "/uri?q2" as "/uri". * 
   
    Default: disable. 

 *cache.debug* 
 writes mod_cache debugging messages to error.log or not 

    Default: disable. 

 *cache.purge-host* 
 PCRE regex hosts IP which are allowed to PURGE cache file 

 e.g.: 

 <pre> 
    cache.purge-host = "^(192\.168\.|222\.120\.35\.)" # Allow PURGE from 192.168/16 and 222.120.35/24, plus hardcoded 10/8 and 127.0.0.1 
 </pre> 

    Default: not set (10/8 and 127.0.0.1 are hardcoded to ip lists which allow to PURGE) 

 *cache.ignore-hostname* 
 don't include hostname in cache saving filename 

    Default: disable. 

 *cache.refresh-pattern* 
 arrays of    "url_pcre_regex" => "minutes options". Zero minute means cache forever. multi options are allowed. 


 *refresh-pattern options are:* 

 |_.option |_.description |  
 | ignore-reload | do not update cache when browser sends 'Cache-Control: no-cache' header |  
 | update-on-refresh | update cache when browser sends 'Cache-Control: no-cache' header |  
 | override-expire | ignore backend's 'Expire' header while determining whether to cache |  
 | ignore-cache-control-header | ignore backend's 'Cache-Control' headers while determining whether to cache |  
 | no-expire-header | do not set expires header on matched uri. without this options mod_cache set expire header based refresh-pattern rule |  
 | fetchall-for-range-request | download all content of file if browser sends 'Range: xxx-yyybytes' header. it is useful for multi-thread downloaders(such as flashget) |  
 | flv-streaming | to work with mod_flv_streaming |  
 | nocache | do not cache matched url |  

 Examples