nginx反向代理缓存提速

https://www.iteye.com/blog/836811384-1977332

http{
    proxy_cache_path  /opt/cache  levels=1:2 keys_zone=STATIC:10m inactive=96h max_size=40g;  
    server {
        listen 81; 
        #location ^~ /
        location /img {  
            proxy_pass             http://server.usa.com;  
            proxy_set_header       X-Forwarded-For $proxy_add_x_forwarded_for;  
            proxy_cache            STATIC;  
            proxy_cache_valid      200  10d;  
            proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;  
        }
    }
}

提速明显。

proxy_cache_path /tmp levels=1:2 keys_zone=cache_one:500m inactive=1d max_size=30g;

add_header Cache-Control 'public';
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cache_one;
proxy_cache_valid  200 206 304 180d; 
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;

参考:

https://www.cnblogs.com/f-ck-need-u/p/7684732.html

https://www.cnblogs.com/chenpython123/p/11974576.html

https://www.cnblogs.com/redirect/p/10066766.html#23-proxy_cache

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache

原文地址:https://www.cnblogs.com/tekikesyo/p/15539907.html