Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX Bypass static caching through static-main.php when GET or POST…

… parameters are set (regression from 2.3 API, fixes #5519, thanks ktauber) (from r103961)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112327 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit 683cf79fe6fe6d3079998e8bfe6e3cf926918454 1 parent 80f609e
@chillu chillu authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 static-main.php
View
12 static-main.php
@@ -22,8 +22,15 @@
$hostmapLocation = '../subsites/host-map.php';
$homepageMapLocation = '../assets/_homepage-map.php';
-if ($cacheEnabled && empty($_COOKIE['bypassStaticCache'])) {
-
+if (
+ $cacheEnabled
+ && empty($_COOKIE['bypassStaticCache'])
+ // No GET params other than cache relevant config is passed (e.g. "?stage=Stage"),
+ // which would mean that we have to bypass the cache
+ && count(array_diff(array_keys($_GET), array('url', 'cacheSubdir'))) == 0
+ // Request is not POST (which would have to be handled dynamically)
+ && count($_POST) == 0
+) {
// Define system paths (copied from Core.php)
if(!defined('BASE_PATH')) {
// Assuming that this file is sapphire/static-main.php we can then determine the base path
@@ -75,6 +82,7 @@
// Find file by extension (either *.html or *.php)
$file = preg_replace('/[^a-zA-Z0-9\/\-_]/si', '-', $file);
+
if (file_exists($cacheBaseDir . $cacheDir . $file . '.html')) {
header('X-SilverStripe-Cache: hit at '.@date('r'));
echo file_get_contents($cacheBaseDir . $cacheDir . $file . '.html');
Please sign in to comment.
Something went wrong with that request. Please try again.