[英]nginx webpy fastcgi caching can not work
nginx.conf file content as follow: nginx.conf文件内容如下:
http {
include mime.types;
default_type application/octet-stream;
# configure cache log
log_format cache '$remote_addr - $host [$time_local] '
'"$request" $status $upstream_cache_status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
fastcgi_cache_path /data0/nginx-cache levels=1:2
keys_zone=nginx_fastcgi_cache:1m
inactive=1d;
fastcgi_temp_path /data0/nginx-cache/temp;
server {
listen 8080;
server_name outofmemory.cn localhost;
access_log /data0/nginx-1.2.6/logs/cache.log cache;
#charset koi8-r;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache nginx_fastcgi_cache;
fastcgi_cache_min_uses 1;
fastcgi_ignore_headers Cache-Control Expires;
fastcgi_cache_use_stale error timeout invalid_header http_500;
#add_header X-Cache cached;
fastcgi_cache_valid 60m;
location / {
root /www/outofmemory.cn;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9002;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache nginx_fastcgi_cache;
fastcgi_cache_valid 60m;
}
}
}
any help would be appreciated. 任何帮助,将不胜感激。
thanks. 谢谢。
I also having the same problem. 我也有同样的问题。 As yukaizhao mentioned in his post, need to added below to ignore expires header or else fastcgi_cache won't work. 正如yukaizhao在他的帖子中提到的,需要在下面添加忽略expires头,否则fastcgi_cache将无效。
fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
Thanks yukaizhao! 谢谢你yukaizhao!
I have resolved this question. 我已经解决了这个问题。
I wrote an artile to explain how to configure nginx + webpy + fastcgi cache. 我写了一篇文章来解释如何配置nginx + webpy + fastcgi缓存。
http://outofmemory.cn/code-snippet/2154/nginx-webpy-fastcgi-cache-configuration-explain-in-detail http://outofmemory.cn/code-snippet/2154/nginx-webpy-fastcgi-cache-configuration-explain-in-detail
thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.