分类: LINUX
2010-02-04 14:55:10
最近FW Session极度上升,快逼近256k的上线,所以想加入一些用户端的缓存来减少请求。
注意对于一些不常变化的静态目录加入exprise.
一 lighttpd
1 根据目录来缓存
expire.url = (
"/xx/" => "access 168 hours",
"/xxxx/attach/" => "access 168 hours",
"/xxx/" => "access 2 months
分别设置目录缓存为一周,和2个月
2 根据文件来缓存
另外还可以根据图片的格式来缓存
$HTTP["url"] =~ "\.(jpg|jpeg|gif|png|css|js)" {
expire.url = ( "" => "access 24 hours" )
}
注意:我在lighttpd-1.4.19 上用文件形式未成功,升级到lighttpd/1.4.25就可以了。
附:expire参数
The and directives can also be defined in a more readable syntax of the form:
ExpiresDefault " [plus] { }*"
ExpiresByType type/encoding " [plus] { }*"
where
The 'plus' keyword is optional.
For example, any of the following directives can be used to make documents expire 1 month after being accessed, by default:
ExpiresDefault "access plus 1 month"
ExpiresDefault "access plus 4 weeks"
ExpiresDefault "access plus 30 days"
The expiry time can be fine-tuned by adding several '
ExpiresByType text/html "access plus 1 month 15 days 2 hours"
ExpiresByType image/gif "modification plus 5 hours 3 minutes"