通过location配置
location ~ \.html$ { add_header 'Cache-Control' 'no-cache'; } location ~ \.(js|css|gif|jpg|jpeg|png|bmp|swf)$) { access_log off; expires 7d; }
在location内配置
location ^~ /testpath { if ($uri ~ \.html$) { add_header 'Cache-Control' 'no-cache'; } if ($uri ~ \.(js|css|gif|jpg|jpeg|png|bmp|swf)$) { access_log off; expires 7d; } ... }