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
|
||||
*/
|
||||
return [
|
||||
'allow_get_input' => true,
|
||||
'empty_global_arrays' => true,
|
||||
'restore_global_arrays' => true,
|
||||
// General
|
||||
'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~%.:_\-',
|
||||
'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_',
|
||||
'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
|
||||
{
|
||||
// If empty, index page is requested
|
||||
$selector = empty($selector) ? 'index' : $selector;
|
||||
// If output cache is disabled, don't return a cache result
|
||||
if ($this->config->get('cache_output') !== true)
|
||||
return false;
|
||||
|
||||
// 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
|
||||
if ($this->compressOutput)
|
||||
$file = Core::$tempDir . DS . 'OutputCache' . DS . md5($uri) . '_gzip.fwcache';
|
||||
$file = Core::$tempDir . DS . 'OutputCache' . DS . $identier . '_gzip.fwcache';
|
||||
else
|
||||
$file = Core::$tempDir . DS . 'OutputCache' . DS . md5($uri) . '.fwcache';
|
||||
|
||||
$file = Core::$tempDir . DS . 'OutputCache' . DS . $identier . '.fwcache';
|
||||
|
||||
// Determine if file exists
|
||||
if (!file_exists($file))
|
||||
|
@ -259,6 +263,10 @@ class 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
|
||||
$cachePath = Core::$tempDir . DS . 'OutputCache';
|
||||
|
||||
|
@ -278,12 +286,16 @@ class Output
|
|||
|
||||
// Generate the full uri
|
||||
$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
|
||||
if ($this->compressOutput)
|
||||
$file = $cachePath . DS . md5($uri) . '_gzip.fwcache';
|
||||
$file = $cachePath . DS . $identier . '_gzip.fwcache';
|
||||
else
|
||||
$file = $cachePath . DS . md5($uri) . '.fwcache';
|
||||
$file = $cachePath . DS . $identier . '.fwcache';
|
||||
|
||||
|
||||
// If compression is enabled, compress the output
|
||||
|
|
Loading…
Reference in New Issue