Nginx 全站缓存

location / {
        proxy_cache cache_one;
        proxy_cache_valid  200 304 1d; #Cache for 1Days
        proxy_cache_key $host$uri$is_args$args;
        proxy_redirect      off;
        proxy_pass          http://1.1.1.1;
        proxy_set_header Host   $host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_ignore_headers Cache-Control;
        proxy_hide_header Cache-Control;
        proxy_ignore_headers Expires;
        proxy_hide_header Expires;
        proxy_hide_header Set-Cookie;
        proxy_ignore_headers Set-Cookie;
}

之前对于 nginx cache,站点的首页不能缓存,之后加入下面这段之后,忽略头部,就可以缓存了。
location / {
        ...
        proxy_ignore_headers Cache-Control;
        proxy_hide_header Cache-Control;
        proxy_ignore_headers Expires;
        proxy_hide_header Expires;
        proxy_hide_header Set-Cookie;
        proxy_ignore_headers Set-Cookie;
}

标签:Linux, Nginx