shuber 2005/03/07 15:15:38 CET
Modified files:
core/src/java/org/jahia/operations/valves CacheWriteValve.java
Log:
Fix for JAHIA-268 : jParams.setCacheExpirationDate & Delay cannot really
deactivate page cache
- Setting a past date in the jParams.setCacheExpirationDate or using
setCacheExpirationDelay(0) will now prevent the page from being cached.
Revision Changes Path
1.2 +18 -11
jahia/core/src/java/org/jahia/operations/valves/CacheWriteValve.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/operations/valves/CacheWriteValve.java.diff?r1=1.1&r2=1.2&f=h
Index: CacheWriteValve.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/operations/valves/CacheWriteValve.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CacheWriteValve.java 24 Jun 2004 17:33:45 -0000 1.1
+++ CacheWriteValve.java 7 Mar 2005 14:15:37 -0000 1.2
@@ -107,6 +107,18 @@
CacheEntry newEntry = new CacheEntry(htmlEntry);
newEntry.setOperationMode(jParams.getOperationMode());
+ // Cannot proceed if the user information is not available
+ if (jParams.getUser () == null)
+ return;
+
+ // Add the entry to the cache
+ String entryKey = htmlCache.computeEntryKey (
+ Integer.toString (jParams.getPageID ()),
+ jParams.getUser ().getUsername (),
+ languageCode,
+ workflowState,
+ jParams.getUserAgent ());
+
// compute the entry's expiration date
if (jParams.settings().getOutputCacheDefaultExpirationDelay() !=
-1) {
Date nowDate = new Date();
@@ -123,20 +135,15 @@
// if a default expiration date has been set, us this instead.
if (jParams.getCacheExpirationDate() != null) {
logger.debug("Using default expiration date");
+ Date nowDate = new Date();
+ if (nowDate.compareTo(jParams.getCacheExpirationDate()) >=
0) {
+ // cache will expire immediately -> we don't cache the
+ // page.
+ return;
+ }
newEntry.setExpirationDate(jParams.getCacheExpirationDate());
}
- // Cannot proceed if the user information is not available
- if (jParams.getUser() == null)
- return;
-
- // Add the entry to the cache
- String entryKey = htmlCache.computeEntryKey(
- Integer.toString(jParams.getPageID()),
- jParams.getUser().getUsername(),
- languageCode,
- workflowState,
- jParams.getUserAgent());
htmlCache.putCacheEntry(entryKey, newEntry, true);
logger.debug("Added HTML page into the cache.");