Chinaunix首页 | 论坛 | 博客
  • 博客访问: 631587
  • 博文数量: 95
  • 博客积分: 2091
  • 博客等级: 大尉
  • 技术积分: 982
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-05 19:34
文章分类

全部博文(95)

文章存档

2017年(1)

2016年(20)

2015年(10)

2014年(6)

2013年(4)

2012年(1)

2011年(9)

2010年(6)

2009年(20)

2008年(17)

2007年(1)

我的朋友

分类: 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 is one of:

  • access
  • now (equivalent to 'access')
  • modification

The 'plus' keyword is optional. should be an integer value [acceptable to atoi()], and is one of:

  • years
  • months
  • weeks
  • days
  • hours
  • minutes
  • seconds

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 ' ' clauses:

ExpiresByType text/html "access plus 1 month 15 days 2 hours"
ExpiresByType image/gif "modification plus 5 hours 3 minutes"


 

阅读(1724) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~