Nginx 缓存的配置一例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
proxy_cache_path /home/web/cache levels=1:2 keys_zone=mydomain:100m inactive=50m max_size=20m;  

server {
  listen 80;
  server_name mydomain.com www.mydomain.com;

  location / {
    proxy_pass http://localhost:8080;
    proxy_temp_path /home/web/temp;
    proxy_cache mydomain;
    proxy_cache_valid 200 302 1h;
    proxy_cache_valid 301 1d;
    proxy_cache_valid any 1m;
}
}