配置 – 如何为Jetty的web.xml中的静态资源配置缓存?

我在读这个:
http://docs.codehaus.org/display/JETTY/LastModifiedCacheControl

它说

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>

但是,我不确定我使用的是默认的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>
相关文章
相关标签/搜索