changeset 111:adf7b11921f4

No compression when debugging. Synchronize caching headers.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Tue, 15 Mar 2016 12:55:42 +0100
parents 6f5939bf53c3
children 4854db07f14f
files CacheTimeCheck.inc FileCacheSet.inc InputParser.inc Page.inc constants.inc
diffstat 5 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CacheTimeCheck.inc	Tue Mar 08 00:43:48 2016 +0100
+++ b/CacheTimeCheck.inc	Tue Mar 15 12:55:42 2016 +0100
@@ -26,15 +26,15 @@
     //print_r($gmdate_mod);
   }
 
+  foreach($cache->cacheControl() as $header => $value) {
+    header ("${header}: ${value}");
+  }
   if(array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
     $HTTP_IF_MODIFIED_SINCE = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
     $if_modified_since = preg_replace('/;.*$/', '', $HTTP_IF_MODIFIED_SINCE);
 
     if (strtotime($if_modified_since) >= $cache->getNewest()) {
       header("HTTP/1.0 304 Not Modified");
-      foreach($cache->cacheControl() as $header => $value) {
-	header ("${header}: ${value}");
-      }
       return false;
     }
   }
--- a/FileCacheSet.inc	Tue Mar 08 00:43:48 2016 +0100
+++ b/FileCacheSet.inc	Tue Mar 15 12:55:42 2016 +0100
@@ -13,7 +13,12 @@
   }
 
   function cacheControl() {
-    return array("expires" => toGMTime(time()+$this->max_age), "cache-control" => "public, max-age=$this->max_age");
+    if ($this->max_age > 0) {
+      return array("expires" => toGMTime(time()+$this->max_age), "cache-control" => "public, max-age=$this->max_age");
+    }
+    else {
+      return array("expires" => 0, "cache-control" => "public, max-age=0, no-cache");
+    }
   }
 
 };
--- a/InputParser.inc	Tue Mar 08 00:43:48 2016 +0100
+++ b/InputParser.inc	Tue Mar 15 12:55:42 2016 +0100
@@ -63,7 +63,7 @@
       }
     }
     $this->master = self::getFiles($this->master, $this->options);
-    $cache->setMaxAge(20);
+    $cache->setMaxAge(0);
   }
 
   function cacheCheck()
--- a/Page.inc	Tue Mar 08 00:43:48 2016 +0100
+++ b/Page.inc	Tue Mar 15 12:55:42 2016 +0100
@@ -110,6 +110,8 @@
    */
   function mayCompress()
   {
+    if (COMPRESSION_DISABLED)
+      return false;
     //We want to add the variant even if we don't serve with compression.
     $this->addVariant('Accept-Encoding');
     if (!array_key_exists('HTTP_ACCEPT_ENCODING', $_SERVER))
--- a/constants.inc	Tue Mar 08 00:43:48 2016 +0100
+++ b/constants.inc	Tue Mar 15 12:55:42 2016 +0100
@@ -9,6 +9,7 @@
 define(VERBOSITY_DEBUG, 100);
 
 define(DEBUG_LEVEL, VERBOSITY_NONE);
+define(COMPRESSION_DISABLED, 0);
 
 define(DUMP, 0);
 define(MAX_RECURSE, 50);