1

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;
    }

    }
}

任何帮助,将不胜感激。

谢谢。

4

2 回答 2

3

我也有同样的问题。正如 yukaizhao 在他的帖子中提到的,需要在下面添加以忽略 expires 标头,否则 fastcgi_cache 将不起作用。

fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";

谢谢玉开昭!

于 2013-09-14T08:18:05.363 回答
1

我已经解决了这个问题。

我写了一篇文章来解释如何配置nginx + webpy + fastcgi缓存。

http://outofmemory.cn/code-snippet/2154/nginx-webpy-fastcgi-cache-configuration-explain-in-detail

谢谢。

于 2013-02-06T01:22:11.880 回答