Nginx反向代理缓存Proxy Cache配置

配置示例:

proxy_cache_path /mnt/cache levels=1:2 keys_zone=ctohome:50m inactive=1d max_size=10g;  
proxy_cache_key  "$host$request_uri";  
server {  
    listen       80;
    server_name  xxx.xxx.xxx;
    location / {
        proxy_pass   http://xxx.xxx.xxx;
        proxy_redirect          off;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        Host            $host;

        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;

        client_max_body_size       10m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_cache ctohome; 
        proxy_cache_valid 200 302 12h; 
        proxy_cache_valid 301 1d; 
        proxy_cache_valid any 1h; 

        proxy_buffer_size          4k;
        proxy_buffers              4 32k; 

        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }    
}