今天测试nginx的按时间缓存,发现两个问题:
1 proxy_cache_purge的1.0版本安装到0.8.54版本会出错,请安装1.3版本,否则清除缓存时curl会收到“curl: (52) Empty reply from server”,没法清除缓存
2 proxy_store和它是冲突的,proxy_store off才行,如果http段全局有on,那就在这里需要声明off
安装proxy_cache_purge你可以访问这里查看到官方提供的第三方插件http://wiki.nginx.org/3rdPartyModules
访问 http://labs.frickle.com/nginx_ngx_cache_purge/查看具体配置方式
关于安装的文章太多,不重复。
缓存的特点:
md5值分段截取为文件夹
1,2层级的目录是md5值的后面1个字符和2个字符作为文件夹的
有记KEY值和相应的头信息
清除缓存的响应:
原创内容如转载请注明:来自 阿权的书房
1 proxy_cache_purge的1.0版本安装到0.8.54版本会出错,请安装1.3版本,否则清除缓存时curl会收到“curl: (52) Empty reply from server”,没法清除缓存
2 proxy_store和它是冲突的,proxy_store off才行,如果http段全局有on,那就在这里需要声明off
安装proxy_cache_purge你可以访问这里查看到官方提供的第三方插件http://wiki.nginx.org/3rdPartyModules
访问 http://labs.frickle.com/nginx_ngx_cache_purge/查看具体配置方式
引用
#### proxy_cache_path 指令指定缓存的路径和一些其他参数,缓存的数据存储在文件中。缓存的文件名和key为代理URL的MD5 码。levels参数指定缓存的子目录数,所有活动的key和元数据存储在共享的内存区域中,这个区域用keys_zone参数指定,keys_zone指定缓存的名字和共享内存大小,如果在inactive参数指定的时间内缓存的数据没有被请求则被删除,默认inactive为10分钟。cache manager进程控制磁盘的缓存大小,在max_size参数中定义,超过其大小后最少使用数据将被删除。
proxy_cache_path /www/ng_cache levels=1:2 keys_zone=tmp_cache:1000m inactive=1d max_size=10000m;
proxy_cache_path /www/ng_cache levels=1:2 keys_zone=tmp_cache:1000m inactive=1d max_size=10000m;
关于安装的文章太多,不重复。
缓存的特点:
md5值分段截取为文件夹
1,2层级的目录是md5值的后面1个字符和2个字符作为文件夹的
有记KEY值和相应的头信息
[root@aslibra nginx]# head d/8a/353329a20615078e7391e2c4d091e8ad
?;AN????O9AN??
?=???
KEY: www.aslibra.com/test/beijing/
HTTP/1.1 200 OK
Server: nginx/0.8.15
Date: Tue, 09 Aug 2011 13:42:40 GMT
Content-Type: text/html; charset=utf-8
Connection: close
X-Powered-By: PHP/5.2.10
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">....
?;AN????O9AN??
?=???
KEY: www.aslibra.com/test/beijing/
HTTP/1.1 200 OK
Server: nginx/0.8.15
Date: Tue, 09 Aug 2011 13:42:40 GMT
Content-Type: text/html; charset=utf-8
Connection: close
X-Powered-By: PHP/5.2.10
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">....
清除缓存的响应:
[root@aslibra nginx-0.8.54]# curl -H "host:www.aslibra.com" 127.0.0.1/purge/test/
<html>
<head><title>Successful purge</title></head>
<body bgcolor="white">
<center><h1>Successful purge</h1>
<br>Key : www.aslibra.com/test/
<br>Path: /Data/cache/nginx/d/8a/353329a20615078e7391e2c4d091e8ad
</center>
<hr><center>nginx/0.8.54</center>
</body>
</html>
[root@aslibra nginx-0.8.54]# curl -H "host:www.aslibra.com" 127.0.0.1/purge/test/
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/0.8.54</center>
</body>
</html>
<html>
<head><title>Successful purge</title></head>
<body bgcolor="white">
<center><h1>Successful purge</h1>
<br>Key : www.aslibra.com/test/
<br>Path: /Data/cache/nginx/d/8a/353329a20615078e7391e2c4d091e8ad
</center>
<hr><center>nginx/0.8.54</center>
</body>
</html>
[root@aslibra nginx-0.8.54]# curl -H "host:www.aslibra.com" 127.0.0.1/purge/test/
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/0.8.54</center>
</body>
</html>
原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
_SERVER["PHP_SELF"]没有值的修复
gzip格式图片的解压
