Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions PicoZCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,13 @@ class PicoZCache extends AbstractPicoPlugin
private $cacheXHTML = false;
private $cacheFileName;

public function onConfigLoaded(array &$settings)
{
if (isset($config['cache_dir'])) {

// ensure cache_dir ends with '/'
$lastchar = substr($config['cache_dir'], -1);
if ($lastchar !== '/') {
$config['cache_dir'] = $config['cache_dir'].'/';
}
$this->cacheDir = $config['cache_dir'];
}
if (isset($config['cache_time'])) {
$this->cacheTime = $config['cache_time'];
}
if (isset($config['cache_enabled'])) {
$this->doCache = $config['cache_enabled'];
}
if (isset($config['cache_xhtml_output'])) {
$this->cacheXHTML = $config['cache_xhtml_output'];
}
}
public function onConfigLoaded(array &$config)
{
$this->doCache = $this->getPluginConfig('enabled', false);
$this->cacheTime = $this->getPluginConfig('time', 604800);
$this->cacheXHTML = $this->getPluginConfig('xhtml_output', false);
$this->cacheDir = trim($this->getPluginConfig('dir', 'content/cache/'),'/').'/';
}

public function onRequestUrl(&$url)
{
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ To install the Pico Cache plugin, simply download the `PicoZCache.php` and put i

In config.yml you can change default caching settings:
```yaml
cache_enabled: true # True/False if cache is enabled
cache_dir: content/cache/ # Directory where cache should be saved
cache_time: 604800 # Interval between caching (period from one to second cache) in seconds, here is 7 days = 60 * 60 * 24 * 7.
cache_xhtml_output: false # If true, XHTML Content-Type header will be sent when loading cache page
PicoZCache:
enabled: true # True/False if cache is enabled
dir: cache/html/ # Directory where cache should be saved
time: 604800 # Interval between caching (period from one to second cache) in seconds, here is 7 days = 60 * 60 * 24 * 7.
xhtml_output: false # If true, XHTML Content-Type header will be sent when loading cache page
```

## Cache clearing
Expand Down