客户端(浏览器)访问服务器上的资源后,会缓存在浏览器中,对于一些经常变更的静态资源,我们可以设置缓存时间,也就是设置静态资源的过期时间

[root@localhost ~]$ cat /usr/local/nginx/conf/vhost/test.com.conf 
server {
    listen 80;
    server_name www.test.com;
    index index.html index.html index.php;
    root /data/www;
  
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires 7d;
    }

location ~ .*\.(js|css)$ {
expires 12h;
} }

 

 

 

 

 

 

 

    

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
猜你喜欢
  • 2022-12-23
  • 2021-12-17
  • 2021-10-09
  • 2021-06-18
相关资源
相似解决方案