diff --git a/services/Htmlcache_HtmlcacheService.php b/services/Htmlcache_HtmlcacheService.php
index ad34407..a1ac2c2 100644
--- a/services/Htmlcache_HtmlcacheService.php
+++ b/services/Htmlcache_HtmlcacheService.php
@@ -33,7 +33,7 @@ public function checkForCacheFile()
ob_start();
}
}
-
+
public function canCreateCacheFile()
{
// Skip if we're running in devMode
@@ -58,7 +58,7 @@ public function canCreateCacheFile()
if (craft()->request->isLivePreview()) {
return false;
}
-
+
// Skip if it's a post/ajax request
if (!craft()->request->isGetRequest()) {
return false;
@@ -66,10 +66,23 @@ public function canCreateCacheFile()
return true;
}
-
+
+ public function header_sent($header) {
+ $headers = headers_list();
+ $header = trim($header,': ');
+ $result = false;
+
+ foreach ($headers as $hdr) {
+ if (strpos($hdr, $header) !== false) {
+ $result = true;
+ }
+ }
+ return $result;
+ }
+
public function createCacheFile()
{
- if ($this->canCreateCacheFile() && http_response_code() == 200) {
+ if ($this->canCreateCacheFile() && !$this->header_sent("No-Cache") && http_response_code() == 200) {
$content = ob_get_contents();
ob_end_flush();
$file = $this->getCacheFileName();
@@ -83,7 +96,7 @@ public function createCacheFile()
}
}
}
-
+
public function clearCacheFiles()
{
// @todo split between all/single cache file
@@ -92,17 +105,17 @@ public function clearCacheFiles()
}
return true;
}
-
+
private function getCacheFileName($withDirectory = true)
{
return \htmlcache_filename($withDirectory);
}
-
+
private function getCacheFileDirectory()
{
return \htmlcache_directory();
}
-
+
public function log($settings, $errors, $level)
{
// Firstly, store in plugin log file (use $level to control log level)