github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

mcurry / html_cache

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 16
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

CakePHP Plugin - Store a Cake generated page as plain HTML — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

don't cache if posted data or flash messages 
mcurry (author)
Fri Jan 08 07:52:35 -0800 2010
commit  f7810e3ad8ee9252b71880cb504fc7c9adc2c0f1
tree    01e87ccc364280b6fa5bf50585a1783c225b9c62
parent  fccae8f89a6e81d7e82d6b8e388d0a2fc77d8327
html_cache /
name age
history
message
file README Wed Jan 06 20:06:14 -0800 2010 updated htaccess rewrite in README to match sam... [mcurry]
directory controllers/ Fri Jan 08 07:51:56 -0800 2010 clear cache on delete actions [mcurry]
directory extras/ Fri May 08 21:26:12 -0700 2009 made into plugin; added tests [unknown]
directory tests/ Fri May 08 21:26:12 -0700 2009 made into plugin; added tests [unknown]
directory views/ Fri Jan 08 07:52:35 -0800 2010 don't cache if posted data or flash messages [mcurry]
README
/*
 * HtmlCache Plugin
 * Copyright (c) 2009 Matt Curry
 * http://pseudocoder.com
 * http://github.com/mcurry/html_cache
 *
 * @author      mattc <matt@pseudocoder.com>
 * @license     MIT
 *
 */
 
/* About */
Cake's core cache helper is great, but the files it outputs are PHP files, so it will never be as fast as
straight HTML files. This HTML Cache Helper writes out pure HTML, meaning the web server doesn't have to
touch PHP when a request is made.  Included is also a Croogo CMS (http://croogo.org) using the hooks system.

This plugin is for sites with high traffic pages that have nothing unique about the user on the page. I
use this helper on http://www.rsstalker.com. It handles the custom RSS feeds (currently around 13k), which
is perfect since there is nothing user specific in the XML. Each feed gets hit multiple times a day, by
multiple aggregators. This really adds up to a ton of requests.
 
/* Notes */
  * Nothing specific to a user on the page. No "Welcome, Matt" or shopping carts.
  * Cache will never expire (for non-Croogo version). See below for workaround.

/* Instructions */
  * Include the helper in your controller:
    $helpers = array('HtmlCache.HtmlCache');
  * Or in a single action
    $this->helpers[] = 'HtmlCache.HtmlCache';
  * Update your webroot .htaccess file to include the following lines before CakePHP's Rewrite Cond
    (see extras/webroot.htaccess for an example):
    RewriteCond %{REQUEST_METHOD} ^GET$
    RewriteCond %{DOCUMENT_ROOT}/cache/$1/index.html -f
    RewriteRule ^(.*)$ /cache/$1/index.html [L]

/* Croogo Instructions */
  * Update your webroot .htaccess file to include the following lines before CakePHP's Rewrite Cond
    (see extras/webroot.htaccess for an example):
    RewriteCond %{DOCUMENT_ROOT}/cache/$1/index.html -f
    RewriteRule ^(.*)$ /cache/$1/index.html [L]
  * In the Croogo admin go to Extensions -> Hooks and active both the component and helper.
  * The Croogo version will automatically delete the cached file if there is a change to the content or a comment is 
  added.
    
/* Tips */
  * To expire the cache I use a cron job which deletes old files from the directory.
  find /full/path/to/app/webroot/cache -mmin +360 | xargs rm -f
  * A sample htaccess file, cache.htaccess is included that will additionally gzip the cached files
  for even better performance.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server