Chinaunix

标题: nginx cache不缓存的一个问题 [打印本页]

作者: cnleon    时间: 2012-04-06 13:36
标题: nginx cache不缓存的一个问题
nginx cache的基本配置如下
  1.     more_clear_headers 'Set-Cookie';
  2.     more_clear_headers 'Cookie';
  3.     more_clear_headers 'P3P';
  4.     proxy_cache_use_stale updating;
  5.     proxy_cache_path /cache/default.cac levels=1:2 keys_zone=default:1024m max_size=2g inactive=30d;

  6.     include upstreams;

  7.     server {
  8.         proxy_set_header real_ip_header X-Real-IP;
  9.         proxy_set_header Host $http_host;
  10.         proxy_set_header Forwarded-For $remote_addr;
  11.         set $compress "non-gzip";
  12.         if ($http_accept_encoding ~* gzip) {set $compress "gzip";}
  13.         proxy_cache_key "$host$uri$is_args$args$compress";


  14.         listen       80;
  15.         server_name  1.1.1.1;


  16.         access_log  logs/cache.access.log  cache;

  17.         location / {
  18.                 proxy_cache default;
  19.                 proxy_cache_methods GET HEAD POST;
  20.                 proxy_cache_min_uses 1;
  21.                 proxy_cache_valid 200 1d;
  22.                 proxy_cache_valid 404 504 301 1m;
  23.                 proxy_cache_valid any 0m;
  24.                 proxy_temp_path /cache/default.tmp;
  25.                 proxy_pass http://static;
  26.                 allow all;
  27.                 if ( $request_method = "PURGE" ) {
  28.                         rewrite ^(.*)$ /purge$1 last;
  29.                 }
  30.         }
复制代码
现在的问题是当用浏览器访问的时候可以hit,但是用wget 模拟的时候却不可以
wget -S   --header="Accept-Encoding:gzip,deflate" --header="Host:www.abc.com" http://1.1.1.1/icon.jpg
然后在缓存目录中也没有东西。但是浏览器访问却能正常缓存。
作者: FaintKnowledge    时间: 2012-04-06 16:34
回复 1# cnleon


    加一个 --no-cache 参数看看呢?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2