Changed output cache to include GET parameters as cache key.
This allows more dynamic pages to cache pages based on the exact request.
This commit is contained in:
parent
74cb630d80
commit
1180445dcc
|
@ -34,13 +34,32 @@
|
||||||
* @version Version 1.2.0
|
* @version Version 1.2.0
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
'allow_get_input' => true,
|
// General
|
||||||
'empty_global_arrays' => true,
|
|
||||||
'restore_global_arrays' => true,
|
|
||||||
'base_url' => '',
|
'base_url' => '',
|
||||||
|
'serverName' => 'FuzeWorks',
|
||||||
|
|
||||||
|
// Whether to allow GET parameters
|
||||||
|
'allow_get_input' => true,
|
||||||
|
|
||||||
|
// Clears the global $_GET, $_POST, $_COOKIE and $_SERVER arrays in order to prevent misuse
|
||||||
|
'empty_global_arrays' => true,
|
||||||
|
|
||||||
|
// Whether to restore the $_GET, $_POST, $_COOKIE and $_SERVER arrays when FuzeWorks shuts down
|
||||||
|
'restore_global_arrays' => true,
|
||||||
'permitted_uri_chars' => 'a-z 0-9~%.:_\-',
|
'permitted_uri_chars' => 'a-z 0-9~%.:_\-',
|
||||||
'charset' => 'UTF-8',
|
'charset' => 'UTF-8',
|
||||||
'compress_output' => false,
|
|
||||||
|
// Whether to gzip the output when the client supports it
|
||||||
|
'compress_output' => true,
|
||||||
|
|
||||||
|
// Global switch for output cache. To use, must be enabled in view as well
|
||||||
|
'cache_output' => true,
|
||||||
|
'xss_clean' => true,
|
||||||
|
|
||||||
|
// Cookie settings
|
||||||
'cookie_prefix' => 'FWZ_',
|
'cookie_prefix' => 'FWZ_',
|
||||||
'xss_clean' => true
|
'cookie_domain' => '',
|
||||||
|
'cookie_path' => '/',
|
||||||
|
'cookie_secure' => false,
|
||||||
|
'cookie_httponly' => false
|
||||||
];
|
];
|
|
@ -201,18 +201,22 @@ class Output
|
||||||
|
|
||||||
public function getCache(string $selector): bool
|
public function getCache(string $selector): bool
|
||||||
{
|
{
|
||||||
// If empty, index page is requested
|
// If output cache is disabled, don't return a cache result
|
||||||
$selector = empty($selector) ? 'index' : $selector;
|
if ($this->config->get('cache_output') !== true)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Generate the full uri
|
// Generate the full uri
|
||||||
$uri = $this->config->get('base_url') . $selector;
|
$uri = $this->config->get('base_url') . (empty($selector) ? 'index' : $selector);
|
||||||
|
$getParams = $this->input->get();
|
||||||
|
|
||||||
|
// Determine the identifier
|
||||||
|
$identier = md5($uri . '|' . serialize($getParams));
|
||||||
|
|
||||||
// Determine the file that holds the cache
|
// Determine the file that holds the cache
|
||||||
if ($this->compressOutput)
|
if ($this->compressOutput)
|
||||||
$file = Core::$tempDir . DS . 'OutputCache' . DS . md5($uri) . '_gzip.fwcache';
|
$file = Core::$tempDir . DS . 'OutputCache' . DS . $identier . '_gzip.fwcache';
|
||||||
else
|
else
|
||||||
$file = Core::$tempDir . DS . 'OutputCache' . DS . md5($uri) . '.fwcache';
|
$file = Core::$tempDir . DS . 'OutputCache' . DS . $identier . '.fwcache';
|
||||||
|
|
||||||
|
|
||||||
// Determine if file exists
|
// Determine if file exists
|
||||||
if (!file_exists($file))
|
if (!file_exists($file))
|
||||||
|
@ -259,6 +263,10 @@ class Output
|
||||||
|
|
||||||
public function writeCache(string $output)
|
public function writeCache(string $output)
|
||||||
{
|
{
|
||||||
|
// If output cache is disabled, don't create a cache entry
|
||||||
|
if ($this->config->get('cache_output') !== true)
|
||||||
|
return false;
|
||||||
|
|
||||||
// First create cache directory
|
// First create cache directory
|
||||||
$cachePath = Core::$tempDir . DS . 'OutputCache';
|
$cachePath = Core::$tempDir . DS . 'OutputCache';
|
||||||
|
|
||||||
|
@ -278,12 +286,16 @@ class Output
|
||||||
|
|
||||||
// Generate the full uri
|
// Generate the full uri
|
||||||
$uri = $this->config->get('base_url') . (empty($this->uri->uriString()) ? 'index' : $this->uri->uriString());
|
$uri = $this->config->get('base_url') . (empty($this->uri->uriString()) ? 'index' : $this->uri->uriString());
|
||||||
|
$getParams = $this->input->get();
|
||||||
|
|
||||||
|
// Determine the identifier
|
||||||
|
$identier = md5($uri . '|' . serialize($getParams));
|
||||||
|
|
||||||
// Determine the file that holds the cache
|
// Determine the file that holds the cache
|
||||||
if ($this->compressOutput)
|
if ($this->compressOutput)
|
||||||
$file = $cachePath . DS . md5($uri) . '_gzip.fwcache';
|
$file = $cachePath . DS . $identier . '_gzip.fwcache';
|
||||||
else
|
else
|
||||||
$file = $cachePath . DS . md5($uri) . '.fwcache';
|
$file = $cachePath . DS . $identier . '.fwcache';
|
||||||
|
|
||||||
|
|
||||||
// If compression is enabled, compress the output
|
// If compression is enabled, compress the output
|
||||||
|
|
Loading…
Reference in New Issue