title: Tomcat 8 caches static files allthough configured otherwise
body: <p>My Problem:</p>
  
  <p>When I access a static file served from comcat 8 over http the content of the file is cached server sidely.
  I can rule the following errors out:</p>
  
  <ol>
  <li>it's not my browser cache (disabled, tried different browsers, used wget on cli). Tomcat is returning with http 200 OK</li>
  <li>It's <a href="https://stackoverflow.com/questions/11333462/tomcat-cant-see-newly-created-static-files-and-is-server-side-caching-the-old-f">not an configuration issue with a conflicting antiResourceLocking</a></li>
  <li>I don't thinks it's an configuration issue? (see below)</li>
  </ol>
  
  <p>Here's my server.xml (I know it's not so nice to put the contexts in here..)</p>
  
  
  
  <pre><code>&lt;Server port="8005" shutdown="SHUTDOWN"&gt;
    &lt;Listener className="org.apache.catalina.startup.VersionLoggerListener" /&gt;
    &lt;Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /&gt;
    &lt;Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /&gt;
    &lt;Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /&gt;
    &lt;Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /&gt;
  
    &lt;GlobalNamingResources&gt;
  
      &lt;Resource name="UserDatabase" auth="Container"
                type="org.apache.catalina.UserDatabase"
                description="User database that can be updated and saved"
                factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                pathname="conf/tomcat-users.xml" /&gt;
    &lt;/GlobalNamingResources&gt;
  
  
    &lt;Service name="Catalina"&gt;
  
      &lt;Connector port="8888" protocol="HTTP/1.1"
                 connectionTimeout="20000"
                 redirectPort="8443" /&gt;
  
          &lt;!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --&gt;
          &lt;Connector
             protocol="org.apache.coyote.http11.Http11NioProtocol"
             port="8883" maxThreads="200"
             socketBuffer="-1"
             scheme="https" secure="true" SSLEnabled="true"
             keystoreFile="/vagrant/provision/configFiles/keystore" keystorePass="changeit"
             clientAuth="false" sslProtocol="TLS"/&gt;
  
      &lt;Engine name="Catalina" defaultHost="localhost"&gt;
  
        &lt;Realm className="org.apache.catalina.realm.LockOutRealm"&gt;
          &lt;Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 resourceName="UserDatabase"/&gt;
        &lt;/Realm&gt;
  
             &lt;Host name="www.xxx.de"  appBase="webapps"&gt;
                          &lt;Valve className="org.apache.catalina.valves.rewrite.RewriteValve" /&gt;
                          &lt;Context path="" docBase="/vagrant/webroot/xxx"&gt;
                            &lt;Resources cachingAllowed="false" /&gt;
                          &lt;/Context&gt;
                          &lt;Context path="/r2d2" docBase="/vagrant/webroot/r2d2"/&gt;
                          &lt;Context path="/data" docBase="/vagrant/webroot/shares/data"/&gt;
            &lt;/Host&gt;
  
      &lt;/Engine&gt;
    &lt;/Service&gt;
  &lt;/Server&gt;
  </code></pre>
  
  <p>And this is my context.xml</p>
  
  <pre><code>&lt;Context&gt;
      &lt;Resources cachingAllowed="false" /&gt;
  
      &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
      &lt;WatchedResource&gt;${catalina.base}/conf/web.xml&lt;/WatchedResource&gt;
  
  &lt;/Context&gt;
  </code></pre>
  
  <p>The context xml resources tag is only for paranoia. The server.xml resources tag should be enough without the resources tag in context.xml right?
  However, here is what I have observed:</p>
  
  <p>When I change the file in the webroot, tomcat changes the content-length accordingly (!). So it is actually detecting that the file is changed. But the content is still wrong (adding NUL chars at the end of the file, when I put more content in it on filesystem). I always get 200 ok responses.
  It does work perfectly for small files, but not for "larger" files like ~> 45172 bytes</p>
  
  <p>My webapps and work folder is empty(!).</p>
  
  <p>Even if I restart tomcat, the file is still cached server side.. And this is where I lost my mind: Where is tomcat getting the old file contents from? I even read the sourcecode on github from tomcat and I've seen that the contents of cached files are stored in memory.. I grepped for parts of the cached file and found nothing. </p>
  
  <p>For more Infos: the tomcat is running in vagrant, but it does not matter if I modify the file on the guest or on the host. From file system (guest and host) the file is changed, tomcat response is 200 but the wrong content is delivered.</p>
  
  <p>tomcat-8.0.28 running.</p>
  
  <p>No more ideas left :( Thank you in advance.
  Philipp</p>