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;
}
}
}
任何帮助将不胜感激。
感谢。
答案 0 :(得分:3)
我也有同样的问题。正如yukaizhao在帖子中提到的,需要在下面添加忽略expires头,否则fastcgi_cache将无效。
fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
谢谢yukaizhao!
答案 1 :(得分:1)
我已经解决了这个问题。
我写了一篇文章来解释如何配置nginx + web py + fastcgi缓存。
http://outofmemory.cn/code-snippet/2154/nginx-webpy-fastcgi-cache-configuration-explain-in-detail
感谢。