Skip to content
Static cache for Fuelphp framework. Render output to real files and serve them improving performance.
Branch: master
Clone or download
Pull request Compare This branch is 1 commit ahead of floorish:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
classes
config
README.md
bootstrap.php

README.md

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]   
You can’t perform that action at this time.