Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

HTML cache tested and working for page view

  • Loading branch information...
commit 53cde19b9c0dc7ede7ed78c70b12afa1795abbf3 1 parent 253f606
@klevo authored
View
7 .htaccess
@@ -6,7 +6,12 @@
# Maitenance mode: (uncoment following line)
# RewriteRule ^(.*)$ app/webroot/offline.html [L]
+
+ # HTML cache
+ RewriteCond %{REQUEST_METHOD} ^GET$
+ RewriteCond %{DOCUMENT_ROOT}/wildflower/app/webroot/cache/$1/index.html -f
+ RewriteRule ^(.*)$ app/webroot/cache/$1/index.html [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
-</IfModule>
+</IfModule>
View
9 app/.htaccess
@@ -3,12 +3,3 @@
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
-
-<IfModule mod_deflate.c>
- # compress content with type html,
- AddOutputFilterByType DEFLATE text/html application/rss+xml
- <IfModule mod_headers.c>
- # properly handle requests coming from behind proxies
- Header append Vary User-Agent
- </IfModule>
-</IfModule>
View
1  app/app_controller.php
@@ -272,6 +272,7 @@ function beforeRender() {
'isPosts' => false,
'isHome' => $this->isHome,
'homePageId' => $this->homePageId,
+ // Here without base
'here' => substr($this->here, strlen($this->base) - strlen($this->here)),
);
$this->params['Wildflower']['view'] = $params;
View
2  app/config/core.php
@@ -38,7 +38,7 @@
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
- Configure::write('debug', 1);
+ Configure::write('debug', 0);
/**
* Application wide charset encoding
*/
View
5 app/webroot/.htaccess
@@ -1,9 +1,6 @@
<IfModule mod_rewrite.c>
RewriteEngine On
- RewriteCond %{REQUEST_METHOD} ^GET$
- RewriteCond %{DOCUMENT_ROOT}/cache/$1/index.html -f
- RewriteRule ^(.*)$ /cache/$1/index.html [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
-</IfModule>
+</IfModule>
View
4 wildflower/config/core.php
@@ -30,5 +30,7 @@
'blogIndex' => 'blog',
// Disabling the root page cache may be useful in debugging
// (the cache file won't be created, page routes load from the database)
- 'disableRootPageCache' => false
+ 'disableRootPageCache' => false,
+ // 60000% speed increase with pure HTML caching into the webroot
+ 'htmlCache' => true
)));
View
13 wildflower/controllers/wild_pages_controller.php
@@ -8,13 +8,20 @@
class WildPagesController extends AppController {
public $components = array('RequestHandler', 'Seo');
- public $helpers = array('Cache', 'Form', 'Html', 'Text', 'Time', 'Wildflower.List', 'Wildflower.Tree');
+ public $helpers = array('Form', 'Html', 'Text', 'Time', 'List', 'Tree');
public $paginate = array(
'limit' => 25,
'order' => array('WildPage.lft' => 'asc')
);
public $pageTitle = 'Pages';
+ function beforeFilter() {
+ parent::beforeFilter();
+ if (Configure::read('Wildflower.htmlCache') and $this->params['action'] == 'view') {
+ $this->helpers[] = 'HtmlCache';
+ }
+ }
+
/**
* A static about Wildflower page
*
@@ -301,10 +308,6 @@ function getChildPagesForMenu($pageSlug) {
* Handles redirect if the correct url for page is not entered.
*/
function view() {
- if (Configure::read('AppSettings.cache') == 'on') {
- $this->cacheAction = 60 * 60 * 24 * 3; // Cache for 3 days
- }
-
// Parse attributes
$args = func_get_args();
$corrected = false;
View
45 wildflower/views/helpers/html_cache.php
@@ -7,33 +7,34 @@
* http://www.pseudocoder.com/archives/2008/09/03/cakephp-html-cache-helper/
*
* @author mattc <matt@pseudocoder.com>
+ * @modifiedBy klevo for Wildflower
* @license MIT
- *
*/
-
class HtmlCacheHelper extends Helper {
- function afterLayout() {
- if (Configure::read('debug') > 0) {
- return;
- }
+
+ function afterLayout() {
+ if (Configure::read('debug') > 0) {
+ return;
+ }
- $view =& ClassRegistry::getObject('view');
+ $view = ClassRegistry::getObject('view');
- //handle 404s
- if ($view->name == 'CakeError') {
- $path = $this->params['url']['url'];
- } else {
- $path = $this->here;
- }
+ //handle 404s
+ if ($view->name == 'CakeError') {
+ $path = $this->params['url']['url'];
+ } else {
+ $path = substr($this->here, strlen($this->base) - strlen($this->here));
+ }
- $path = implode(DS, array_filter(explode('/', $path)));
- if($path !== '') {
- $path = DS . ltrim($path, DS);
- }
- $path = WWW_ROOT . 'cache' . $path . DS . 'index.html';
+ $path = implode(DS, array_filter(explode('/', $path)));
+ if($path !== '') {
+ $path = DS . ltrim($path, DS);
+ }
+ $path = WWW_ROOT . 'cache' . $path . DS . 'index.html';
- $file = new File($path, true);
- $file->write($view->output);
- }
+ $file = new File($path, true);
+ $file->write($view->output);
+ }
+
}
-?>
+
Please sign in to comment.
Something went wrong with that request. Please try again.