This Gist describes how to tune HTTP browser cache expiration for static contents served by Wildfly Undertow web server, as per RFC-2616 section 13.
In order to change HTTP browser cache behavior, a "Cache-Control" HTTP header has to be added to static content HTTP responses returned by Undertow.
NOTE: "..." means existing xml config elements to be kept
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
...
<server name="default-server">
...
<host name="default-host" alias="localhost">
...
<filter-ref name="custom-max-age" predicate="path-suffix['.js'] or path-suffix ['.json'] or path-suffix ['.html'] or path-suffix ['.css'] or path-suffix ['.jpg'] or path-suffix ['.jpeg'] or path-suffix ['.png'] or path-suffix ['.gif']"/>
</host>
</server>
...
<filters>
...
<response-header name="custom-max-age" header-name="Cache-Control" header-value="max-age=600, public"/>
</filters>
</subsystem>
A Cache-Control header will be added to HTTP responses header for static files having extensions: ".js, .json, .html, .css, .jpg, .jpeg, .png, .gif". (Complete list of handlers predicates, such as "path-suffix", is availaible here)
This header has a "max-age=600, public" value which tells to browser to expire these static content files after 600 seconds, as described in RFC-2616 section 14.9.3. (see this other section for public value description)
- RFC-2616 - section 13, section 14.9.3 and section 14.9.1
- Predicates Attributes and Handlers
@tggm. I had tested this setting with Wildfly 8.
From what I understand with ETAG the browser does not request the resource automatically after its expiration if the fingerprint is still the same. So it's not the same caching behavior as with max-age header setting described here. See this article.