views:

444

answers:

1

I was reading this: http://docs.codehaus.org/display/JETTY/LastModifiedCacheControl

It says "The Jetty default servlet allows the cache control header to be set for static content by using the cacheControl init parameter using

<init-param>
 <param-name>cacheControl</param-name>
 <param-value>max-age=3600,public</param-value>
</init-param>

"

However, I am not sure that I am using the default servlet. At least such configuration is not in 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>

I would like to configure cache for static resources such as:

 /src/webapp/* ,i.e.,
 (/src/webapp/images, /src/webapp/css, /src/webapp/js, etc.)

What should I add into my web.xml?

+1  A: 

Need to add the following to your 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>
With wicket the static resources are actually served with WicketServlet, so this does not help :(
Martin
Oh, I see. I think within your Application.init() you need to set the following.getResourceSettings().setDefaultCacheDuration(3600);