a6266318 发表于 2018-12-5 11:13:31

tomcat7 设置静态资源的expires过期时间

http://tomcat.apache.org/tomcat-7.0-doc/images/void.gifhttp://tomcat.apache.org/tomcat-7.0-doc/images/void.gifhttp://tomcat.apache.org/tomcat-7.0-doc/images/void.gif
ExpiresFilter
org.apache.catalina.filters.ExpiresFilter

ExpiresByType image
access plus 10 minutes


ExpiresByType text/css
access plus 10 minutes


ExpiresByType application/javascript
access plus 10 minutes


...

ExpiresFilter
/*
REQUEST
  
  

  相关链接:http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Expires_Filter
  

  补充:运行上述代码,js文件可能无法达到预期效果,可将application/javascript改成text/javascript,再调试一下啊(这可能是官方文档的疏忽,也可能是因为我是采用requirejs管理js文件的缘故,读者可以根据自身情况调试)。
  




页: [1]
查看完整版本: tomcat7 设置静态资源的expires过期时间