"Revalidating" simply means reading from the disk again. Therefore if a client requests a static resource:
- if the resource was read less than
cacheTtl
seconds ago, the data cached in Java's heap memory will be returned,
- if the resource was read more than
cacheTtl
seconds ago, Tomcat will read the data from disk again (and cache it).
Since memory access is an order of magnitude faster than disk access (cf. this question), if the cache is not full, a longer TTL means better performance. When the cache becomes full (above 90% capacity), Tomcat can evict cache entries before they reach their TTL.
The real performance impact of Tomcat caching is however much more complex because:
- modern operating systems cache open files themselves (using the RAM not used by applications), therefore a "disk read" might actually be almost as fast as a "heap memory read". Decreasing Tomcat's memory might sometimes improve performance,
- modern operating systems have a sendfile system call: if you want to return a file to the client as-is, the OS can do it for you (much faster than Java code). Tomcat's
DefaultServlet
by default uses sendfile
(cf. documentation) for files larger than 48 KiB. There is no need to cache files larger than that.