paulsp 01/10/26 21:31:19
Modified: src/java/org/apache/jetspeed/modules/pages
JetspeedTemplatePage.java
webapp/WEB-INF/conf JetspeedResources.properties
Log:
o Set HTTP cache related headers based on JR.p parameter http.lifetime.
o Set default cache lifetime = 5 seconds
PR: Bug #4468
Revision Changes Path
1.16 +22 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/pages/JetspeedTemplatePage.java
Index: JetspeedTemplatePage.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/pages/JetspeedTemplatePage.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- JetspeedTemplatePage.java 2001/07/22 20:31:11 1.15
+++ JetspeedTemplatePage.java 2001/10/27 04:31:19 1.16
@@ -73,6 +73,7 @@
import org.apache.jetspeed.capability.CapabilityMapFactory;
import org.apache.jetspeed.services.TemplateLocator;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
+import org.apache.jetspeed.services.resources.JetspeedResources;
//<Temporary FIX: new turbine will make it obsolete>
import org.apache.turbine.services.localization.LocaleDetector;
@@ -126,10 +127,13 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">John D. McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
- * @version $Id: JetspeedTemplatePage.java,v 1.15 2001/07/22 20:31:11 raphael Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Paul Spencer</a>
+ * @version $Id: JetspeedTemplatePage.java,v 1.16 2001/10/27 04:31:19 paulsp Exp $
*/
public class JetspeedTemplatePage extends DefaultPage
{
+ private static int httpLifetime = JetspeedResources.getInt("http.lifetime", -1);
+
/**
* Works with TemplateService to set up default templates and
* corresponding class modules.
@@ -139,6 +143,23 @@
*/
protected void doBuildAfterAction(RunData data) throws Exception
{
+
+ switch (httpLifetime) {
+ case -1:
+ break;
+ case 0:
+ data.getResponse().setHeader("Cache-Control", "no-cache");
+ data.getResponse().setHeader("Pragma", "no-cache");
+ data.getResponse().setDateHeader("Expires", 0);
+ data.getResponse().setDateHeader("Last-Modified",
System.currentTimeMillis());
+ break;
+ default:
+ data.getResponse().setHeader("Cache-Control", "max-age=" + httpLifetime);
+ data.getResponse().setDateHeader("Expires", System.currentTimeMillis() +
(httpLifetime * 1000));
+ data.getResponse().setDateHeader("Last-Modified",
System.currentTimeMillis());
+ break;
+ }
+
// Either template or screen should be guaranteed by the SessionValidator
// It is occasionally better to specify the screen instead of template
// in cases where multiple Screens map to one template. The template
1.42 +18 -1
jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
Index: JetspeedResources.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- JetspeedResources.properties 2001/10/13 08:11:35 1.41
+++ JetspeedResources.properties 2001/10/27 04:31:19 1.42
@@ -1,7 +1,7 @@
################################################################################
# Jetspeed Configuration
# Author: Kevin A. Burton ([EMAIL PROTECTED])
-# $Id: JetspeedResources.properties,v 1.41 2001/10/13 08:11:35 paulsp Exp $
+# $Id: JetspeedResources.properties,v 1.42 2001/10/27 04:31:19 paulsp Exp $
################################################################################
# This is the main file you will need to configuration Jetspeed. If there are
# any secondary files they will be pointed to from this file.
@@ -400,4 +400,21 @@
confirm.email.name=Jetspeed Postmaster
confirm.email.subject=Jetspeed registration
confirm.email.enable=false
+
+#########################################
+# HTTP Page header #
+#########################################
+# http.lifetime is the lifetime of the page as set in the
+# HTTP Headers
+# -1 = Do not set cache related headers (Jetspeed 1.3a1 behavior)
+# 0 = set the following http headers
+# Cache-Control = "no-cache"
+# Last-Modified = (current time)
+# Pragma = "no-cache"
+# Expires = "0"
+# n where n is the number of seconds:
+# Cache-Control = "max-age: n" where n is the number of seconds
+# Last-Modified = (current time)
+# Expires = (current time + n seconds)
+http.lifetime=5
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]