HTTP Etag on wildfly 10.
tiago.matias Feb 16, 2017 5:38 AMHello,
I'm trying to add ETAG's to my http resposes. The objective is to make the browser cache static contents like javascript, CSS and image files. I've added the vary-header and a cache-control header (with max-age=600, public) to the responses. However the browser refuses to cache these files (confirmed with fiddler).
As far as I could gather, an Etag header is necessary but I can find no documentation explaining how to configure it for Undertow. This is my configuration so far:
<subsystem xmlns="urn:jboss:domain:undertow:3.1"> <buffer-cache name="default"/> <server name="default-server"> <http-listener name="default" socket-binding="http" redirect-socket="https"/> <host name="default-host" alias="localhost"> <location name="/" handler="welcome-content"/> <filter-ref name="gzipFilter" predicate="exists['%{o,Content-Type}'] and regex[pattern='(?:application/javascript|text/css|text/html|text/xml|application/json)(;.*)?', value=%{o,Content-Type}, full-match=true]"/> <filter-ref name="Vary-header"/> <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> <servlet-container name="default"> <jsp-config/> <websockets/> </servlet-container> <handlers> <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/> </handlers> <filters> <response-header name="Vary-header" header-name="Vary" header-value="Accept-Encoding"/> <response-header name="custom-max-age" header-name="Cache-Control" header-value="max-age=600, public"/> <gzip name="gzipFilter"/> </filters> </subsystem>
Can anyone share a solution?
Many thanks in advance!