Nginx cache configuration and update cache, negotiation cache

General cache configuration example

# 静态文件
location ~ ^/web/.*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    
    
  expires 20d;
  access_log off;
}
location ~ ^/web/.*\.(js|css)?$ {
    
    
  expires 7d;
  access_log off;
}

Example for Configuring the Negotiation Cache

Solved the problem that static resources are not updated after modification

  # 公共静态页面
location / {
    
    
  add_header Cache-Control no-cache; # 加上这个响应头,表示协商缓存,解决了静态资源修改后不更新的问题
  index index.html index.htm;
}

Guess you like

Origin blog.csdn.net/u014438244/article/details/125034540