summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'cache.start.php')
-rw-r--r--cache.start.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/cache.start.php b/cache.start.php
new file mode 100644
index 0000000..c3b8270
--- /dev/null
+++ b/cache.start.php
@@ -0,0 +1,35 @@
+<?
+
+ if(!$nocache) {
+ require_once 'Cache/Lite.php';
+
+ $cache_id = md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
+
+ if($_COOKIE)
+ $cache_id = md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] . md5(implode(" ", array_keys($_COOKIE))));
+
+ // Use /tmp/znurt if we can hack it
+ if((!is_dir("/tmp/znurt") && mkdir("/tmp/znurt")) || (is_dir("/tmp/znurt") && is_writable("/tmp/znurt")))
+ $cache_tmp_dir = "/tmp/znurt/";
+ else
+ $cache_tmp_dir = "/tmp/";
+
+ $cache_options = array(
+ 'cacheDir' => $cache_tmp_dir,
+ 'lifeTime' => 3600,
+ );
+
+ $cache = new Cache_Lite($cache_options);
+ if($znurt && $data = $cache->get($cache_id)) {
+ echo $data;
+ die;
+ }
+
+ // Start caching if on live site
+ if($znurt && !$nocache) {
+ // Start caching
+ ob_start();
+ }
+ }
+
+?> \ No newline at end of file