通过expires指令,将指定后缀的请求设置缓存。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| upstream localblog { server 192.168.0.108:4000; }
server { listen 80; server_name 192.168.0.108; client_max_body_size 1000M; sendfile on;
location / { #root /opt/dist; proxy_pass http://localblog; index index.html;
if ($request_filename ~* ^.*?\.(ico|jpg|jpeg|gif|png|woff|woff2|bmp|js|css)$) { expires 1d; } } }
|
可参考知识点
- Last-Modified/If-Modified-Since
- Etag/If-None-Match
- Cache-Control: max-age和expires
- Expires