remove built-in full-page caching; it doesn't do much any more, and everything it does do can be done better by Varnish

This commit is contained in:
Shish 2012-06-18 00:07:12 +01:00
parent 5519c3a320
commit 930de7fc8c
2 changed files with 0 additions and 96 deletions

View file

@ -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 *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

View file

@ -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) {