[pLog-svn] r2265 - in plog/branches/plog-1.0.2/class: net/http summary/view view

oscar at devel.plogworld.net oscar at devel.plogworld.net
Wed Jun 22 11:22:03 GMT 2005


Author: oscar
Date: 2005-06-22 11:22:02 +0000 (Wed, 22 Jun 2005)
New Revision: 2265

Modified:
   plog/branches/plog-1.0.2/class/net/http/httpcache.class.php
   plog/branches/plog-1.0.2/class/summary/view/summarycachedview.class.php
   plog/branches/plog-1.0.2/class/view/smartyview.class.php
Log:
fixed issue 602 (http://bugs.plogworld.net/view.php?id=602)


Modified: plog/branches/plog-1.0.2/class/net/http/httpcache.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/net/http/httpcache.class.php	2005-06-22 10:52:51 UTC (rev 2264)
+++ plog/branches/plog-1.0.2/class/net/http/httpcache.class.php	2005-06-22 11:22:02 UTC (rev 2265)
@@ -96,7 +96,7 @@
 			//rfc2616-sec14.html#sec14.19 //='"0123456789abcdef0123456789abcdef"'
 			if (isset($SERVER['QUERY_STRING'])) $myQuery='?'.$SERVER['QUERY_STRING'];
 			else $myQuery='';
-			$etagServer='"'.md5($scriptName.$myQuery.'#'.$dateLastModif).'"';
+			$etagServer='"'.md5($scriptName.$myQuery.'#'.$dateLastModif).'"';			
 			
 			if ((!$is412)&&isset($SERVER['HTTP_IF_MATCH']))
 			{//rfc2616-sec14.html#sec14.24
@@ -138,6 +138,7 @@
 			elseif ($is304&&($nbCond>0))
 			{//rfc2616-sec10.html#sec10.3.5
 				header('HTTP/1.0 304 Not Modified');
+											
 				header('Etag: '.$etagServer);
 				if ($feedMode) header('Connection: close'); //Comment this line under IIS
 				
@@ -159,6 +160,7 @@
 			else
 			{//rfc2616-sec10.html#sec10.2.1
 			 //rfc2616-sec14.html#sec14.3
+			 
 				if ($compression&&isset($SERVER['HTTP_ACCEPT_ENCODING'])&&
 					extension_loaded('zlib')&&(!ini_get('zlib.output_compression')))
 					ob_start('_httpConditionalCallBack');
@@ -168,6 +170,7 @@
 					$cache='private, must-revalidate, ';
 					//$cacheSeconds=-1500000; //HTTP/1.0
 				}
+
 				elseif ($cachePrivacy==0) $cache='private, ';
 				elseif ($cachePrivacy==2) $cache='public, ';
 				else $cache='';

Modified: plog/branches/plog-1.0.2/class/summary/view/summarycachedview.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/summary/view/summarycachedview.class.php	2005-06-22 10:52:51 UTC (rev 2264)
+++ plog/branches/plog-1.0.2/class/summary/view/summarycachedview.class.php	2005-06-22 11:22:02 UTC (rev 2265)
@@ -84,7 +84,22 @@
 			print $this->_template->fetch( $this->_viewId );		
 		}
 					
+		function getCacheTimeSeconds()
+		{
+			$config =& Config::getConfig();
+			
+			$cacheTime = $config->getValue( "template_cache_lifetime" );
+			
+			if( $cacheTime == "" || !is_numeric($cacheTime))
+				$cacheTime = 1; // [almost] no value, just one second of caching
+			if( $cacheTime == -1 )
+				$cacheTime = 788400000; // a veeery long time!
+			if( $cacheTime > 788400000)
+				$cacheTime = 788400000;
 
+			return( $cacheTime );
+		}		
+
         function render()
         {
 			// set the view character set based on the default locale
@@ -99,7 +114,7 @@
 				// some debug information
 				$timestamp = $this->_template->getCreationTimestamp();
 				// and now send the correct headers
-				if( HttpCache::httpConditional( $timestamp ))
+				if( HttpCache::httpConditional( $timestamp, $this->getCacheTimeSeconds()))
 					$sendOutput = false;
 					
 				header( "Last-Modified: ".gmdate('D, d M Y H:i:s', $timestamp).' GMT');	

Modified: plog/branches/plog-1.0.2/class/view/smartyview.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/view/smartyview.class.php	2005-06-22 10:52:51 UTC (rev 2264)
+++ plog/branches/plog-1.0.2/class/view/smartyview.class.php	2005-06-22 11:22:02 UTC (rev 2265)
@@ -149,7 +149,23 @@
 
 			return( $httpCacheEnabled );
 		}
+		
+		function getCacheTimeSeconds()
+		{
+			$config =& Config::getConfig();
+			
+			$cacheTime = $config->getValue( "template_cache_lifetime" );
+			
+			if( $cacheTime == "" || !is_numeric($cacheTime))
+				$cacheTime = 1; // [almost] no value, just one second of caching
+			if( $cacheTime == -1 )
+				$cacheTime = 788400000; // a veeery long time!
+			if( $cacheTime > 788400000)
+				$cacheTime = 788400000;
 
+			return( $cacheTime );
+		}
+
         /**
 		 * Renders the view using the Smarty template object that we created in the constructor. This method
 		 * sends data to the client so it should be called as the last bit of code in our custom classes
@@ -171,7 +187,8 @@
 				// some debug information
 				$timestamp = $this->_template->getCreationTimestamp();
 				// and now send the correct headers
-				if( HttpCache::httpConditional( $timestamp ))
+				
+				if( HttpCache::httpConditional( $timestamp, $this->getCacheTimeSeconds()))
 					$sendOutput = false;
 					
 				$header = "Last-Modified: ".gmdate('D, d M Y H:i:s', $timestamp).' GMT';




More information about the pLog-svn mailing list