cache

NP_Cache.php

Enables caching of nucleus items, homepage, searches and anything off index.php.

General Plugin info
Author: Jim Burnett
Current Version: 1.1.01
Download: -
Code: NP_Cache_code
Demo: -
Forum Thread: Thread 12905

The information about the plugin can also be found on mediauncut This link seems dead, 10-27-2007

How to use the plugin

Speed up your nucleus cms blog tremendously using the NP_Cache plug-in. After a web user visits a page on your site it becomes cached in a temporary directory such as “/tmp”. The next time someone visits, the page is pulled from the cache. This gives your web server and mysql database server a little bit of a break.

For my website, www.mediauncut.com , it made a huge difference. The web server doesn’t have to process skins or templates, and the database doesn’t have to return the skins, templates, plug-in database calls and blog items making my website much quicker then it was before. Not everyone will experience a performance increase, but those of you that get a lot of traffic should notice an increase in traffic. The homepage cache and item cache is reset when you add or update items. If you get a lot of traffic it might be a good idea to delete all your cache files once a month or so.

Whether you use NucleusCMS or another blog, installing a caching mechanism can increase website performance tremendously.

For ultimate performance you will need to edit your root index.php and blog.php files. For each blog you have setup you’ll want to do step 2. Step 2 isn’t required, but will eliminate ALL mysql database calls and pull 100% from cache. If you skip step 2 the plug-in will need to call the database to get your current blog item. Basically the code in Step 2 gets the URL for the page and then parses it to get the correct cached file, if the cache file exists. Otherwise the plug-in creates the cache file because the page has been visited for the first time.

Upgrading

Users of version 1.0 should uninstall the old version, then install the 1.1.x version as described below.

Installing

Copy the NP_Cache_code and save it to a file called NP_Cache.php in your nucleus/plugins directory.

Step 1. ( Step 2 is after the NP_Cache.php code ) Install NP_Cache.php from the Plugin Management page of the Nucleus admin area. After installing, edit the options for the NP_Cache plugin from that same page. Set the cache dir to match the directory on your server. This directory must exist and must be writable by the web server. (1.1)

Make sure the code is between the proper php tags. You will want to change all the /tmp/ lines to point to where your tmp directory is on your server. (1.0.x)

Step 2. This is the code you want to add to the beginning of your root index.php and for each blog. Replace the “/tmp” with the same directory path you set in the plugin options, be sure to surround it in quotes. Add it directly after the <?php line

$a = getenv('REQUEST_URI');
$a = str_replace("/","-",$a);
$a = str_replace("&","-",$a);
$a = str_replace("?","-",$a);
$a = str_replace("=","-",$a);
$cache_file = "/tmp"."/cache" . $a;
 
//If the cache file exists then check the date/time of it.
 
$c_a = $_REQUEST['action'];
if ( $c_a == "addcomment"){
unlink( $cache_file );
}else{
if ( file_exists( $cache_file )) {
require( $cache_file );
die;
}
}

Available SkinVars and/or TemplateVars

Options

Tips and Tricks

Wishlist

Bugs

History

  • Version 1.1, add option, 2008-04-22
  • Version 1.0, initial release, 2006-07-21

Plugin review

NP_Cache version 1.0 works with Nucleus CMS version 3.31 - 2007-10-27 ftruscot

 
cache.txt · Last modified: 2008/06/24 19:25 by vasilek