Skip to content
This repository
Browse code

Fix for Safari's 304 caching 'bug'

Closes #109
  • Loading branch information...
commit 3fe746e2522eb08e98976c1ca946fd2d3e496baa 1 parent 8af32c0
Anthony Kolber authored

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 1 app/stacey.inc.php
5 app/stacey.inc.php
@@ -68,6 +68,9 @@ function set_content_type($template_file) {
68 68
69 69 function etag_expired($cache) {
70 70 header('Etag: "'.$cache->hash.'"');
  71 + # Safari incorrectly caches 304s as empty pages, so don't serve it 304s
  72 + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false) return true;
  73 + # Check for a local cache
71 74 if(isset($_SERVER['HTTP_IF_NONE_MATCH']) && stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) == '"'.$cache->hash.'"') {
72 75 # local cache is still fresh, so return 304
73 76 header("HTTP/1.0 304 Not Modified");
@@ -158,4 +161,4 @@ function __construct($get) {
158 161
159 162 }
160 163
161   -?>
  164 +?>

0 comments on commit 3fe746e

Please sign in to comment.
Something went wrong with that request. Please try again.