From 930de7fc8cb9c007e632dfb7e7a1c9cc3834d1e4 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 18 Jun 2012 00:07:12 +0100 Subject: [PATCH] remove built-in full-page caching; it doesn't do much any more, and everything it does do can be done better by Varnish --- core/util.inc.php | 94 ----------------------------------------------- index.php | 2 - 2 files changed, 96 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 0629e220..8bd37f6a 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1272,100 +1272,6 @@ function _get_user() { } -$_cache_memcache = false; -$_cache_key = null; -$_cache_filename = null; - -function _cache_active() { - return ( - (CACHE_MEMCACHE || CACHE_DIR) && - $_SERVER["REQUEST_METHOD"] == "GET" && - !get_prefixed_cookie("session") && - !get_prefixed_cookie("nocache") - ); -} - -function _cache_log($text) { - $fp = @fopen("data/cache.log", "a"); - if($fp) { - fputs($fp, $text); - fclose($fp); - } -} - -function _start_cache() { - global $_cache_memcache, $_cache_key, $_cache_filename; - - if(_cache_active()) { - if(CACHE_MEMCACHE) { - $_cache_memcache = new Memcache; - $_cache_memcache->pconnect('localhost', 11211); - $_cache_key = "uri:".$_SERVER["REQUEST_URI"]; - $data = $_cache_memcache->get($_cache_key); - if(DEBUG) { - $stat = $zdata ? "hit" : "miss"; - _cache_log(time() . " " . sprintf(" %-4s ", $stat) . $_cache_key . "\n"); - } - if($data) { - header("Content-type: text/html"); - print $data; - exit; - } - } - - if(CACHE_DIR) { - $_cache_hash = md5($_SERVER["QUERY_STRING"]); - $ab = substr($_cache_hash, 0, 2); - $cd = substr($_cache_hash, 2, 2); - $_cache_filename = data_path("http_cache/$ab/$cd/$_cache_hash"); - @chmod(data_path('http_cache'), 750); - - if(file_exists($_cache_filename) && (filemtime($_cache_filename) > time() - 3600)) { - $gmdate_mod = gmdate('D, d M Y H:i:s', filemtime($_cache_filename)) . ' GMT'; - - if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { - $if_modified_since = preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]); - - if($if_modified_since == $gmdate_mod) { - header("HTTP/1.0 304 Not Modified"); - header("Content-type: text/html"); - exit; - } - } - else { - header("Content-type: text/html"); - header('Last-Modified: '.$gmdate_mod); - $zdata = @file_get_contents($_cache_filename); - if(CACHE_MEMCACHE) { - $_cache_memcache->set($_cache_hash, $zdata, 0, 600); - } - $data = @gzuncompress($zdata); - if($data) { - print $data; - exit; - } - } - } - ob_start(); - } - } -} - -function _end_cache() { - global $_cache_memcache, $_cache_key, $_cache_filename; - - if(_cache_active()) { - $data = ob_get_contents(); - if(CACHE_MEMCACHE) { - $_cache_memcache->set($_cache_key, $data, 0, 600); - } - if(CACHE_DIR) { - $zdata = gzcompress($data, 2); - file_put_contents($_cache_filename, $zdata); - } - } -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Code coverage * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/index.php b/index.php index 73793daf..fe48a795 100644 --- a/index.php +++ b/index.php @@ -62,7 +62,6 @@ if(COVERAGE) { } _version_check(); _sanitise_environment(); -_start_cache(); try { // load base files @@ -104,7 +103,6 @@ try { $database->db->commit(); // saving cache data and profiling data to disk can happen later if(function_exists("fastcgi_finish_request")) fastcgi_finish_request(); - _end_cache(); ctx_log_endok(); } catch(Exception $e) {