- 论坛徽章:
- 0
|
nginx cache的基本配置如下- more_clear_headers 'Set-Cookie';
- more_clear_headers 'Cookie';
- more_clear_headers 'P3P';
- proxy_cache_use_stale updating;
- proxy_cache_path /cache/default.cac levels=1:2 keys_zone=default:1024m max_size=2g inactive=30d;
- include upstreams;
- server {
- proxy_set_header real_ip_header X-Real-IP;
- proxy_set_header Host $http_host;
- proxy_set_header Forwarded-For $remote_addr;
- set $compress "non-gzip";
- if ($http_accept_encoding ~* gzip) {set $compress "gzip";}
- proxy_cache_key "$host$uri$is_args$args$compress";
- listen 80;
- server_name 1.1.1.1;
- access_log logs/cache.access.log cache;
- location / {
- proxy_cache default;
- proxy_cache_methods GET HEAD POST;
- proxy_cache_min_uses 1;
- proxy_cache_valid 200 1d;
- proxy_cache_valid 404 504 301 1m;
- proxy_cache_valid any 0m;
- proxy_temp_path /cache/default.tmp;
- proxy_pass http://static;
- allow all;
- if ( $request_method = "PURGE" ) {
- rewrite ^(.*)$ /purge$1 last;
- }
- }
复制代码 现在的问题是当用浏览器访问的时候可以hit,但是用wget 模拟的时候却不可以
wget -S --header="Accept-Encoding:gzip,deflate" --header="Host:www.abc.com" http://1.1.1.1/icon.jpg
然后在缓存目录中也没有东西。但是浏览器访问却能正常缓存。 |
|