Tomcat can't see newly created static files and is server-side caching the old files

jakub.g picture jakub.g · Jul 4, 2012 · Viewed 13.1k times · Source

I use Tomcat 7 on Windows XP.

  • I have a directory with static files (HTML, CSS, JS) in %TOMCATDIR%/webapps/myapplication.
  • They're accessible via localhost:8080/myapplication

When a change happens to a file in my server dir, it is not reflected:

  • modified files are returned (200 OK) the same as previously (tested with Fiddler; for sure not a browser cache issue - cleared cache, using different browsers etc.),
  • newly created files in that directory are not accessible (404).

The above happens no matter how many times I try to reload the file, or even add query string to it (img.jpg?timestamp=...).

In %TOMCATDIR%/conf/context.xml I've set various directives to disable server-side caching:

<?xml version='1.0' encoding='utf-8'?>
<Context antiResourceLocking="true" cachingAllowed="false" cacheMaxSize="1" cacheTTL="1">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

What is wrong?

Answer

jakub.g picture jakub.g · Jul 4, 2012

The solution seems to be remove antiResourceLocking="true".

If anyone's more knowledgable about the topic, or know how to workaround it other way, I'll be grateful.