Skip to content

fuel-packages/fuel-pagecache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fuel-pagecache

Static cache for Fuelphp framework

This is a port of Lysender's kohana module https://github.com/lysender/pagecache

How to

  1. Enable the package in your fuel instance

  2. Create a 'cache' folder in your docroot (or change config to update folder name)

  3. Add this code to the Controller_Template 'before' function:

    $this->pagecache = new Pagecache();
    $this->pagecache->setRequest($this->request);
  1. Add this code to the Controller_Template 'after' function:
    $response = parent::after($response);

    $this->pagecache->setResponse($response);

    if ($this->pagecache->isCacheable()) {
       $this->pagecache->cache($_SERVER['REQUEST_URI']);
    }

    return $response;
  1. Enable cache in your controller

    $this->_pagecache->enableCache();

  2. Update your .htaccess to have the following code

    RewriteRule ^/(.*)/$ /$1 [QSA]
    RewriteRule ^$ cache/index.html [QSA]
    RewriteRule ^([^.]+)/$ cache/$1/index.html [QSA]
    RewriteRule ^([^.]+)$ cache/$1/index.html [QSA]

    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d

    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]   

About

Static cache for Fuelphp framework. Render output to real files and serve them improving performance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published