Author: markt
Date: Wed Sep 18 11:12:02 2013
New Revision: 1524366

URL: http://svn.apache.org/r1524366
Log:
Fix a TODO. Exclude resources in WEB-INF/classes and WEB-INF/lib from
the cache as the class loader has its own caching mechanism.

Modified:
    tomcat/trunk/java/org/apache/catalina/webresources/Cache.java

Modified: tomcat/trunk/java/org/apache/catalina/webresources/Cache.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/Cache.java?rev=1524366&r1=1524365&r2=1524366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/Cache.java (original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/Cache.java Wed Sep 18 
11:12:02 2013
@@ -57,7 +57,9 @@ public class Cache {
 
     protected WebResource getResource(String path) {
 
-        // TODO Should some resources be excluded from caching?
+        if (noCache(path)) {
+            return root.getResourceInternal(path);
+        }
 
         CachedResource cacheEntry = resourceCache.get(path);
 
@@ -137,6 +139,15 @@ public class Cache {
         }
     }
 
+    private boolean noCache(String path) {
+        // Don't cache resources used by the class loader (it has its own 
cache)
+        if (path.startsWith("/WEB-INF/classes") ||
+                path.startsWith("/WEB-INF/lib")) {
+            return true;
+        }
+        return false;
+    }
+
     private long evict(long targetSize, Iterator<CachedResource> iter) {
 
         long now = System.currentTimeMillis();



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to