mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Bypass static caching through static-main.php when GET or POST parameters are set (regression from 2.3 API, fixes #5519, thanks ktauber)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@103961 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
f3e01c98b7
commit
641b93659e
@ -22,8 +22,15 @@ $cacheBaseDir = '../cache/'; // Should point to the same folder as FilesystemPub
|
|||||||
$hostmapLocation = '../subsites/host-map.php';
|
$hostmapLocation = '../subsites/host-map.php';
|
||||||
$homepageMapLocation = '../assets/_homepage-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)
|
// Define system paths (copied from Core.php)
|
||||||
if(!defined('BASE_PATH')) {
|
if(!defined('BASE_PATH')) {
|
||||||
// Assuming that this file is sapphire/static-main.php we can then determine the base path
|
// Assuming that this file is sapphire/static-main.php we can then determine the base path
|
||||||
@ -75,6 +82,7 @@ if ($cacheEnabled && empty($_COOKIE['bypassStaticCache'])) {
|
|||||||
|
|
||||||
// Find file by extension (either *.html or *.php)
|
// Find file by extension (either *.html or *.php)
|
||||||
$file = preg_replace('/[^a-zA-Z0-9\/\-_]/si', '-', $file);
|
$file = preg_replace('/[^a-zA-Z0-9\/\-_]/si', '-', $file);
|
||||||
|
|
||||||
if (file_exists($cacheBaseDir . $cacheDir . $file . '.html')) {
|
if (file_exists($cacheBaseDir . $cacheDir . $file . '.html')) {
|
||||||
header('X-SilverStripe-Cache: hit at '.@date('r'));
|
header('X-SilverStripe-Cache: hit at '.@date('r'));
|
||||||
echo file_get_contents($cacheBaseDir . $cacheDir . $file . '.html');
|
echo file_get_contents($cacheBaseDir . $cacheDir . $file . '.html');
|
||||||
|
Loading…
Reference in New Issue
Block a user