Nginx反代的缓存配置

动态请求不处理:
location ~* .(php|jsp|cgi|asp|aspx)$
{
proxy_pass https://104.19.19.19;
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_set_header REMOTE-HOST $remote_addr;
proxy_ssl_name $host;
proxy_ssl_server_name on;
}

全局不缓存:
location /
{
proxy_pass https://104.19.19.19;
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_set_header REMOTE-HOST $remote_addr;
proxy_ssl_name $host;
proxy_ssl_server_name on;

    add_header X-Cache $upstream_cache_status;
        #Set Nginx Cache
        proxy_ignore_headers Set-Cookie Cache-Control expires;
        add_header Cache-Control no-cache;
    expires 12h;
}

静态资源缓存2天:
location ~* .(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|ico|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma|css|js)$
{
proxy_pass https://104.19.19.19;
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_set_header REMOTE-HOST $remote_addr;
proxy_ssl_name $host;
proxy_ssl_server_name on;

    add_header X-Cache $upstream_cache_status;
        #Set Nginx Cache

    proxy_ignore_headers Set-Cookie Cache-Control expires;
    proxy_cache cache_one;
    proxy_cache_key $host$uri$is_args$args;
    proxy_cache_valid 200 304 301 302 2d;
    expires 12h;
}