我在读这篇文章:
http://docs.codehaus.org/display/JETTY/LastModifiedCacheControl
它说
<init-param>
<param-name>cacheControl</param-name>
<param-value>max-age=3600,public</param-value>
</init-param>
但是,我不确定我是否使用默认的servlet。至少
这样的配置不在web.xml中:
<web-app>
<display-name>Wicket QuickStart</display-name>
<context-param>
<param-name>configuration</param-name>
<param-value>development</param-value>
</context-param>
<servlet>
<servlet-name>quickstart</servlet-name>
<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>wicket.quickstart.WicketApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>quickstart</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
我想为静态资源配置缓存,例如:
/src/webapp/*
,即:/src/webapp/images, /src/webapp/css, /src/webapp/js
等。我应该在
web.xml
中添加什么? 最佳答案
需要将以下内容添加到您的web.xml中
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>cacheControl</param-name>
<param-value>max-age=3600,public</param-value>
</init-param>
</servlet>
关于configuration - 如何在Jetty的web.xml中为静态资源配置缓存?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1906745/