Search code examples
http-headerswildflyundertow

Updating Last-Modified for static content served with Wildfly


I have a war with some static files (mostly images) in the webapp deployed on Wildfly. Sometimes the application needs to update some of those files, which then get replaced in the filesystem.

However Wildfly/Undertow seem to think that nothing has changed and the Last-Modified header in the response keeps showing the time before the update.

So I wonder what is Undertow using to determine the Last-Modified header shown. I've tried "touching" the parent directory, but to no effect.

In fact it looks like wildfly/undertow caches the last modified time after the first time it loaded a given resource.

Update

It's clearly a problem with the cache, since if I remove one of the files I requested before and request it again I get 500 Internal Server Error and stacktrace!


Solution

  • As pointed out in this thread the exploded war directory is not the right place for static resources that can be changed.

    Instead one should use some other directory on the filesystem and configure the undertow subsystem to serve those pages. See for example this question.