[FEATURE] New hook for managing page cache
authorFrancois Suter <francois@typo3.org>
Wed, 25 Jul 2012 07:28:47 +0000 (09:28 +0200)
committerFrancois Suter <francois@typo3.org>
Mon, 30 Jul 2012 07:36:23 +0000 (09:36 +0200)
When pages are cached using some extra system (e.g. nc_staticfilecache)
it is useless to store these as well in whatever cache backend is used.
Thanks to a new hook, storage of a page in cache can be disabled
selectively.

Change-Id: Ie2e3fb61f06a4c0c3238d0644d45895b875686ff
Fixes: #39228
Releases: 6.0
Reviewed-on: http://review.typo3.org/13032
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Julien Henchoz
Tested-by: Julien Henchoz
Reviewed-by: Francois Suter
Tested-by: Francois Suter
typo3/sysext/cms/tslib/class.tslib_fe.php

index 9b88c29..afe0868 100644 (file)
@@ -2789,8 +2789,22 @@ class tslib_fe {
                $cacheTimeout = $this->get_cache_timeout();
                $timeOutTime = $GLOBALS['EXEC_TIME'] + $cacheTimeout;
                $this->tempContent = FALSE;
+               $usePageCache = TRUE;
 
-               $this->setPageCacheContent($this->content, $this->config, $timeOutTime);
+                       // Hook for deciding whether page cache should be written to the cache backend or not
+                       // NOTE: as hooks are called in a loop, the last hook will have the final word (however each
+                       // hook receives the current status of the $usePageCache flag)
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['usePageCache'])) {
+                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['usePageCache'] as $_classRef) {
+                               $_procObj = t3lib_div::getUserObj($_classRef);
+                               $usePageCache = $_procObj->usePageCache($this, $usePageCache);
+                       }
+               }
+
+                       // Write the page to cache, if necessary
+               if ($usePageCache) {
+                       $this->setPageCacheContent($this->content, $this->config, $timeOutTime);
+               }
 
                        // Hook for cache post processing (eg. writing static files!)
                if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'])) {