You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 526 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
jpcache

24.1.1. jpcache

Figure 24-3. Powered by jpcache.

Powered by jpcache.



Enter jpcache: jpcache is a lightweight, full page caching system for PHP, thus reducing server load, as pages are generated less often. It dramatically speeds up serving of your pages, by caching page ouput and returning the chached page instead of compiling the PHP one. In the following we will describe jpcache installation, configuration and use (see also How to accelerate PHP-Nuke):

24.1.1.1. Installation of jpcache

Installation is very simple:

  • Download it from the jpcache download page at sourceforge.net.

  • Extract the files in the includes directory of your PHP-Nuke. A folder "jpcache" will be created containing all the necessary files. Change to that folder.

  • Read the readme file.

24.1.1.2. Configuration of jpcache

  • Edit the $includedir variable in the jpcache.php file to reflect the *full* path to the jpcache files:

    // Set the includedir to the jpcache-directory
    $includedir = "/usr/local/httpd/htdocs/nuke6/html/includes/jpcache";
    
  • Edit the jpcache-config.php file. You basically only need to set the $JPCACHE_TYPE to "file" (remember, we want to avoid database connections):

    $JPCACHE_TYPE = "file";
    //$JPCACHE_TYPE = "mysql";
    //$JPCACHE_TYPE = "dbm"; -- Not yet
    

    then coment the next block (you don't need it, since you *did* specified the $JPCACHE_TYPE above):

    // DOH! Strip out this check for performance if you are sure you did set it.
    // if (!isset($JPCACHE_TYPE))
    // {
    // exit("[jpcache-config.php] No JPCACHE_TYPE has been set!");
    // }
    

    Just check the configuration options to see what they do, the defaults are O.K. for me:

    /**
    * General configuration options. 
    */
    $JPCACHE_TIME = 900; // Default number of seconds to cache a page
    $JPCACHE_DEBUG = 0; // Turn debugging on/off
    $JPCACHE_IGNORE_DOMAIN= 1; // Ignore domain name in request(single site)
    $JPCACHE_ON = 1; // Turn caching on/off
    $JPCACHE_USE_GZIP = 1; // Whether or not to use GZIP
    $JPCACHE_POST = 0; // Should POST's be cached (default OFF)
    $JPCACHE_GC = 1; // Probability % of garbage collection
    $JPCACHE_GZIP_LEVEL = 9; // GZIPcompressionlevel to use (1=low,9=high)
    $JPCACHE_CLEANKEYS = 0; // Set to 1 to avoid hashing storage-key:
    // you can easily see cachefile-origin.
    
  • Finally, set the directory for the cached files, preferably outside your web server root, say /tmp/jpcache. Create it, set the owner and group equal to the owner and group of your web server and change the permissions to 755 (rwx-r-x-r-x), or even 750 (rwx-r-x----). Then, enter in jpcache-config.php the absolute path to that cache directory:

    /**
    * File based caching setting.
    */
    $JPCACHE_DIR = "/tmp/jpcache"; // Directory where jpcache must store 
    // generated files. Please use a dedicated
    // directory, and make it writable
    

That's all! jpcache is now configured correctly.

24.1.1.3. How to use jpcache

To use it, just open the index.php file of your PHP-Nuke and enter the following lines, after the line "require_once("mainfile.php");" (that's important!):

require_once("mainfile.php");
if (!isset($user)) {
  $cachetimeout=900; 
} else {
  $cachetimeout=300;
}
require_once "includes/jpcache/jpcache.php";

(I have included the 'require_once("mainfile.php");' line in the code above for your orientation).

That's it! You can now tweak the two caching intervalls, 900 and 300 seconds, which apply to non-logged-in and logged-in users respectively. Rethink the questions I asked you in Section 24.1 above.

A caching intervall of x seconds means that your server will serve you a cached copy of the page, if the cache copy is not older than x seconds. Since non-logged-in users don't get private messages or similar "events", a longer caching intervall is just right for them. Feel free to experiment with these two values, trading actuality of content against serving speed.

Enjoy your new, lightning fast PHP-Nuke!

Oops...I forgot a crucial detail:

You must edit the mainfile.php file too! There, you *must* comment the line

ob_start("ob_gzhandler");

as follows:

# ob_start("ob_gzhandler");

Otherwise, you will be compressing twofold, once from PHP-Nuke with the above line and once with jpcache through the configuration line

$JPCACHE_USE_GZIP = 1; // Whether or not to use GZIP

of jpcache-config.php.

The other way round, turning off gzip in jpcache and leaving the ob_start("ob_gzhandler") line uncommented in PHP-Nuke, works too. It may even be better to choose this way, if you use Apache and mod_gzip (a common configuration).

Tip How to test if caching is working
 

You can check if you are doing it right, by trying to cache a block that just echoes the current time. If the cached block displays the same time again and again after reloading (for some time interval equal to the "cache interval"), then caching is working!

If it displays the current time (which is changing after every reloading), then caching is NOT working! In this case, most probably no files are being written into the cache directory you specified. Most of the time, this will be a permissions problem: check that the web server has write and execute permissions on the cache directory! See How to accelerate PHP-Nuke.

Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.108 Seconds - 306 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::