mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-25 02:02:57 +01:00
Cache and fetch output by using an Output
object
This commit is contained in:
parent
3d45a15e25
commit
6ad8ad9d0b
@ -150,8 +150,13 @@ class Formwork
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if ($this->option('cache.enabled') && $data = $this->cache->fetch($this->cacheKey)) {
|
||||
echo $data;
|
||||
if ($this->option('cache.enabled') && $output = $this->cache->fetch($this->cacheKey)) {
|
||||
if ($output instanceof Output) {
|
||||
$output->sendHeaders();
|
||||
echo $output->content();
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -170,10 +175,11 @@ class Formwork
|
||||
$this->site->setCurrentPage($resource);
|
||||
}
|
||||
|
||||
$data = $this->site->currentPage()->render();
|
||||
$content = $this->site->currentPage()->render();
|
||||
|
||||
if ($this->option('cache.enabled') && $this->site->currentPage()->cacheable()) {
|
||||
$this->cache->save($this->cacheKey, $data);
|
||||
$output = new Output($content, $this->site->currentPage()->get('response-status'));
|
||||
$this->cache->save($this->cacheKey, $output);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user