免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2672 | 回复: 1
打印 上一主题 下一主题

nginx cache不缓存的一个问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-06 13:36 |只看该作者 |倒序浏览
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
然后在缓存目录中也没有东西。但是浏览器访问却能正常缓存。

论坛徽章:
0
2 [报告]
发表于 2012-04-06 16:34 |只看该作者
回复 1# cnleon


    加一个 --no-cache 参数看看呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP