微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法让nginx缓存工作

我有大多数简单的Nginx配置.我不能让缓存工作

http {
...
server_tokens                   off;
proxy_hide_header               X-Powered-By;
fastcgi_hide_header             X-Powered-By;
client_header_timeout           1024;
client_body_timeout             1024;
send_timeout                    9000;
proxy_read_timeout              4000;
connection_pool_size            256;
client_header_buffer_size       1k;
client_max_body_size            10m;
large_client_header_buffers     2 4k;
request_pool_size               4k;
proxy_buffers                   8 32k;
proxy_buffering                 off;
proxy_buffer_size               32k;
server_names_hash_bucket_size   64;
output_buffers                  3 16k;
postpone_output                 1460;
sendfile                        off;
tcp_nopush                      on;
tcp_nodelay                     on;
keepalive_timeout               30 100;
ignore_invalid_headers          off;
log_format custom '$host $uri $remote_addr [$time_local] $status $bytes_sent [$request]';

proxy_cache_path /var/cache/Nginx/cache levels=1:2 keys_zone=melco:500m inactive=15m max_size=1000m;
proxy_temp_path /var/cache/Nginx/temp;
...

server {
.....
location = /RSS.PHP {
    access_log /var/log/Nginx/RSS.PHP.log custom;
    proxy_cache melco;
    proxy_cache_key "$host$request_uri$args";
    proxy_ignore_headers "Cache-Control" "Expires";
    proxy_cache_min_uses 1;
    proxy_cache_valid 200 302 304 5m;
    proxy_cache_use_stale http_502 http_503 http_504;
    proxy_hide_header Set-Cookie;

    proxy_pass  http://192.168.10.102;
    proxy_redirect     off;
    proxy_set_header    X-Forwarded-For       $remote_addr;
    proxy_set_header   Host             $host;
}
...

标题是:

# curl -I http://mysite.com/RSS.PHP
HTTP/1.1 200 OK
Server: Nginx
Date: Sun,10 Apr 2011 15:45:54 GMT
Content-Type: text/xml; charset=windows-1251
Connection: keep-alive
Keep-Alive: timeout=100
X-Powered-By: PHP/5.3.3-7+squeeze1
Pragma: no-cache
Generator: Nucleus CMS
Etag: "f263dc8eb016ffcb6d34b317b8d5a315"
vary: Accept-Encoding

我可以在/var/log/Nginx/RSS.PHP.log中看到请求,但/ var / cache / Nginx / cache总是空的
/ var / cache / Nginx / cache的权限设置为www-datawww-data(Nginx user:group).
任何想法?如果请求来自缓存,如何在访问日志中查看?

附: Nginx ver:

# Nginx -V
Nginx version: Nginx/0.7.67
TLS SNI support enabled
configure arguments: --conf-path=/etc/Nginx/Nginx.conf --error-log-path=/var/log/Nginx/error.log --http-client-body-temp-path=/var/lib/Nginx/body --http-fastcgi-temp-path=/var/lib/Nginx/fastcgi --http-log-path=/var/log/Nginx/access.log --http-proxy-temp-path=/var/lib/Nginx/proxy --lock-path=/var/lock/Nginx.lock --pid-path=/var/run/Nginx.pid --with-debug --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=/tmp/buildd/Nginx-0.7.67/modules/Nginx-upstream-fair
最佳答案
这都是因为

proxy_buffering                 off;

需要继续进行缓存

原文地址:https://www.jb51.cc/nginx/435265.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐