From 48f200961e13a16c599b7df03f3aa8d402907ea1 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 13 Jul 2009 20:38:37 +0000 Subject: [PATCH] MINOR smarter static-main.php, now detects automatically if you are using domain based cacheing git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@81713 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- static-main.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/static-main.php b/static-main.php index 37878feb1..ef7395ac4 100644 --- a/static-main.php +++ b/static-main.php @@ -12,11 +12,11 @@ if (file_exists('../subsites/host-map.php')) { include_once '../subsites/host-map.php'; - $siteHostmap['default'] = isset($siteHostmap['default']) ? $siteHostmap['default'] : ''; + $subsiteHostmap['default'] = isset($subsiteHostmap['default']) ? $subsiteHostmap['default'] : ''; // Look for the host, and find the cache dir $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); - $cacheDir = (isset($siteHostmap[$host]) ? $siteHostmap[$host] : $siteHostmap['default']) . '/'; + $cacheDir = (isset($subsiteHostmap[$host]) ? $subsiteHostmap[$host] : $subsiteHostmap['default']) . '/'; } else { $cacheDir = ''; } @@ -26,10 +26,13 @@ $file = preg_replace('/[^a-zA-Z0-9]/si', '_', trim($_SERVER['REQUEST_URI'], '/') $file = $file ? $file : 'index'; if (file_exists('../cache/'.$cacheDir.$file.'.html')) { + header('X-cache: hit at '.date('r')); echo file_get_contents('../cache/'.$cacheDir.$file.'.html'); } elseif (file_exists('../cache/'.$cacheDir.$file.'.php')) { + header('X-cache: hit at '.date('r')); include_once '../cache/'.$cacheDir.$file.'.php'; } else { + header('X-cache: miss at '.date('r')); // No cache hit... fallback!!! include 'main.php'; }