A szövetségesek parancsnoksága a közelmúltban szerzett tudomást egy szupertitkos náci atomfegyver fejlesztõ laboratóriumról, ami egy kis farm alatt
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):
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.
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
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!):
(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).
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.