nginx根据location的uri进行不同的缓存配置

html不进行缓存,将js和css文件进行缓存配置

 

   location ^~ /abc {
         if ($request_filename ~* .*\.(?:htm|html)$)
         {
             add_header Cache-Control no-store;
         }
         if ($request_filename ~* .*\.(js|css|jpg|jpeg|gif|png|ico)$)
         {
             add_header Cache-Control max-age=2592000,s-maxage=68400;
         }
         alias /data/www/abc/dist/;
         index index.html index.htm;
         try_files $uri $uri/ /index.html;
    }

 

posted @ 2020-09-10 15:01  林中龙虾  阅读(918)  评论(0编辑  收藏  举报