无法让nginx缓存工作

前端之家收集整理的这篇文章主要介绍了无法让nginx缓存工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

  1. http {
  2. ...
  3. server_tokens off;
  4. proxy_hide_header X-Powered-By;
  5. fastcgi_hide_header X-Powered-By;
  6. client_header_timeout 1024;
  7. client_body_timeout 1024;
  8. send_timeout 9000;
  9. proxy_read_timeout 4000;
  10. connection_pool_size 256;
  11. client_header_buffer_size 1k;
  12. client_max_body_size 10m;
  13. large_client_header_buffers 2 4k;
  14. request_pool_size 4k;
  15. proxy_buffers 8 32k;
  16. proxy_buffering off;
  17. proxy_buffer_size 32k;
  18. server_names_hash_bucket_size 64;
  19. output_buffers 3 16k;
  20. postpone_output 1460;
  21. sendfile off;
  22. tcp_nopush on;
  23. tcp_nodelay on;
  24. keepalive_timeout 30 100;
  25. ignore_invalid_headers off;
  26. log_format custom '$host $uri $remote_addr [$time_local] $status $bytes_sent [$request]';
  27. proxy_cache_path /var/cache/Nginx/cache levels=1:2 keys_zone=melco:500m inactive=15m max_size=1000m;
  28. proxy_temp_path /var/cache/Nginx/temp;
  29. ...
  30. server {
  31. .....
  32. location = /RSS.PHP {
  33. access_log /var/log/Nginx/RSS.PHP.log custom;
  34. proxy_cache melco;
  35. proxy_cache_key "$host$request_uri$args";
  36. proxy_ignore_headers "Cache-Control" "Expires";
  37. proxy_cache_min_uses 1;
  38. proxy_cache_valid 200 302 304 5m;
  39. proxy_cache_use_stale http_502 http_503 http_504;
  40. proxy_hide_header Set-Cookie;
  41. proxy_pass http://192.168.10.102;
  42. proxy_redirect off;
  43. proxy_set_header X-Forwarded-For $remote_addr;
  44. proxy_set_header Host $host;
  45. }
  46. ...

标题是:

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

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

附: Nginx ver:

  1. # Nginx -V
  2. Nginx version: Nginx/0.7.67
  3. TLS SNI support enabled
  4. 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
最佳答案
这都是因为

  1. proxy_buffering off;

需要继续进行缓存

猜你在找的Nginx相关文章