Nginx配置静态文件(浏览器的缓存)

因为服务器带宽只有5M,导致系统访问很慢,所以想利用缓存使访问速度快一些

location ^~ /static/ {
  access_log off;
  add_header Cache-Control max-age=2592000;
  expires                   30d;
  root /usr/share/nginx/html/jijian_web/dist;
}

^~ 表示以/static/开头的任意路径

expires表示超时时间,如果未过期,则浏览器会使用缓存的静态文件

因为使用vueJS,发布时文件名会发生变化,所以更新问题是不存在的

posted @ 2021-05-14 08:41  栖息之鹰  阅读(644)  评论(0编辑  收藏  举报