![]() | ![]() |
![]() | <filter> <filter-name>ExpiresFilter</filter-name> <filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class> <init-param> <param-name>ExpiresByType p_w_picpath</param-name> <param-value>access plus 10 minutes</param-value> </init-param> <init-param> <param-name>ExpiresByType text/css</param-name> <param-value>access plus 10 minutes</param-value> </init-param> <init-param> <param-name>ExpiresByType application/javascript</param-name> <param-value>access plus 10 minutes</param-value> </init-param> </filter> ... <filter-mapping> <filter-name>ExpiresFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> 相关链接:http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Expires_Filter 补充:运行上述代码,js文件可能无法达到预期效果,可将application/javascript改成text/javascript,再调试一下啊(这可能是官方文档的疏忽,也可能是因为我是采用requirejs管理js文件的缘故,读者可以根据自身情况调试)。 |
转载于:https://blog.51cto.com/motouzhixin/1306104