|
Project Information
Featured
Links
|
Summarylighttpd improved is lighttpd 1.4 branch with severals useful modules. We don't choose lighttpd 1.5 because lighttpd 1.5 has no official release till now. Currently mod_cache, mod_mem_compress and mod_mem_cache are included. These modules are written for faster web service, for better user experience. mod_cache is squid-like cache module. mod_mem_cache is to cache local files into memory. mod_mem_compress is to store compress local files into memory How to use mod_cachemod_cache provides following options: - cache.bases: List of cache directories. For examples: cache.bases = ("/data/cache", "/data2/cache")
- cache.enable: Enable or disable modcache, default to enable.
- cache.domains: List of domains which modcache would try to cache for, without it modcache would cache files of every domains. for examples: cache.domains = ("(^|\.)linux\.com\.cn$") caches *.linux.com.cn. domains.
- cache.support-queries: Try to cache query with '?'. default is 'disable'. When cache.support-queries = "enable" and cache.dynamic-mode = "disable", modcache will treat "/uri?q1" or "/uri?q2" as "/uri" and save them to local cache file of "/uri". When cache.support-queries and cache.dynamic-mode are both enabled, modcache will treat "/uri?q1" and "/uri?q2" as different resource and save them to different local cache files.
- cache.debug: Default to disable debug messages.
- cache.purge-host: pcre regex hosts ip which are allowed to PURGE cache files. for examples: cache.purge-host="^200\.100\.1\." allow 200.100.1.0/24 to purge cache
- cache.refresh-pattern: Key of modcache. See section below for detail.
- cache.ignore-hostname: Includes hostname in saved filename or not. default is "disable".
- cache.dynamic-mode: To support dynamic generated web such as forum/bbs. default is "disable". Note: cache.support-queries needs to be enable.(V1.6.0 feature)
- cache.programs-ext: List of local program extension, such as ".php". modcache will replace them with ".cache.html" to aviod confliction with other modules, such as mod_fastcgi. default is not set
- cache.max-memory-size: Number of MBytes which modcache will use to save cached content in memory. default is 256Mbytes.
- cache.lru-remove-count: Number of content removed from memory when memory is full. default is 256.
Refresh Patternscache.refresh-pattern likes squid's refresh-pattern. cache.refresh-pattern format is "url_pcre_regex" => "minutes options". Note: zero 'minutes' means cache forever and minutes option is mandatory. Available refresh-pattern options are: - ignore-reload: Don't update cache when browser sends 'Cache-Control: no-cache' header. It's default behaviour
- 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.
- ignore-vary: Ignore backend's 'Vary' headers while determining whether to cache.
- ignore-set-cookie: Ignore backend's 'Set-Cookie' headers while determining whether to cache. NOTE: improper usage of this option may cause leak of private information, use it carefully
- no-expire-header: Don't set expires header on matched uri. modcache default to set proper expires header based refresh-pattern rules.
- fetchall-for-range-request: Download all content of file if browser sends 'Range: xxx-yyybytes' header. Useful for multi-thread downloaders(such as flashget).
- flv-streaming: to work with mod_flv_streaming.
- use-memory: use memory to save caches instead of local disk (V1.7.0 feature)
- memory-compress: compress memory-saved content for 'Accept-Encoding: gzip, deflate' requests. Note: 1) use mod_compress to compress local cache files(V1.8.0 feature). 2) turn off gzip compress option on backend server
- nocache: Don't cache matched url.
Notes: - mod_cache don't cache urls without refresh-pattern rules matched.
- make sure that mod_cache is loaded before mod_proxy.
- right sequence of modules is server.modules = (..., "mod_mem_compress", "mod_compress", "mod_mem_cache", "mod_cache", "mod_proxy", ...);
Cook Books:For Static Web Server:server.modules = (
# ...., other modules
"mod_cache", # make sure mod_cache loaded before mod_proxy
"mod_proxy"
)
cache.support-queries = "enable"
cache.bases = ("/data/cache")
cache.refresh-pattern = (
"\.(?i)(flv)$" => "0 fetchall-for-range-request flv-streaming",
"\.(?i)(js|css|xml)$" => "240", # update js/css/xml every 4 hours
"\.(?i)(htm|html|shtml)$" => "30 update-on-refresh", #update html/htm/shtml every 30 minutes and on refresh requests
"\.(?i)(jpg|bmp|jpeg|gif|png)$" => "2880",
"\.(?i)(rar|zip|wmv|avi|mp3|ape|rm|mpeg|mpg|wma|asf|rmvb|flv)$" => "0 fetchall-for-range-request",
"." => "30 update-on-refresh"
)
proxy.server = ( "/" =>
(
( "host" => "x.x.x.x", "port" => 80 )
)
)For BBS or Forum serverserver.modules = (
# ...., other modules
"mod_cache",
"mod_proxy"
)
cache.support-queries = "enable"
cache.dynamic-mode = "enable"
cache.bases = ("/data/cache")
cache.refresh-pattern = (
"\.(?i)(flv)$" => "0 fetchall-for-range-request flv-streaming",
"\.(?i)(js|css|xml)$" => "240",
"\.(?i)(htm|html|shtml)$" => "30",
"\.(?i)(jpg|bmp|jpeg|gif|png)$" => "2880",
"\.(?i)(rar|zip|wmv|avi|mp3|ape|rm|mpeg|mpg|wma|asf|rmvb|flv)$" => "0 fetchall-for-range-request",
".(?i)php$" => "5" # update php request every 5 minutes
)
proxy.server = ( "/" =>
(
( "host" => "x.x.x.x", "port" => 80 )
)
)
#cache.programs-ext = (".php") # uncomment this if mod_fastcgi was loaded on this lighttpd serverChangelogStable Version 1.8.3, 02/09/2010 - free hashmap whose size is bigger than 20 for higher hashmap lookup speed
Stable Version 1.8.2, 11/20/2009 - fix bug of freeing shared buffer
Stable Version 1.8.1, 11/01/2009 - 'ignore-set-cookie' option added
- improve performance of mod_cache's memory cache
Stable Version 1.8.0, 06/06/2009 - 'support-accept-encoding' and 'try-gzip-deflate-only' options removed, 'memory-compress' and 'ignore-vary' options added
|