09.18.2009

Jetty browser cache control

by Mike Christianson

Do you use Jetty and need to change the default setting for browser cache control? Have a look at the init-param element named cacheControl in webdefault.xml.

Here’s the default configuration for the version of Jetty I use. Note the element is commented.

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

To enable and configure browser cache control, uncomment and edit the param-value as appropriate. The following example instructs the browser to disable all caching.

<init-param>
      <param-name>cacheControl</param-name>
      <param-value>no-store,no-cache,must-revalidate</param-value>
</init-param>

For information on Cache-Control, see RFC 2616, Section 14.9.

12.03.2008

There’s no law which states web servers and servlet containers must be large, separate pieces of software.  If there were, Jetty would be a dangerous outlaw (possibly even public enemy number one).  Jetty is an open-source embeddable web server and servlet container, written in Java.  It’s small, fast, and easy to embed — perfect for self-contained applications.

Let’s use an example to discover just how easy embedding Jetty can be.  Read more