File: manual.txt

Recommend this page to a friend!
  Classes of Raul Molnar  >  PHP Server and Browser Cache  >  manual.txt  >  Download  
File: manual.txt
Role: Documentation
Content type: text/plain
Description: Documentation ans few more examples
Class: PHP Server and Browser Cache
Cache pages on the server and on the browser side
Author: By
Last change:
Date: 7 years ago
Size: 4,163 bytes



Class file image Download
SIMPLE CACHE  ver.  1.0

1. Introduction

This class can be used for a web page caching purposes.
 You should have writing permission for the caching folder (eg. chmod 666 or 777) !
You should add attached value (for example cookie or session value ) for the logged users !
The caching object should be added right after the initialization of cookie session !

2. Usage:

a) basic usage

	// in this case i created the folder "cache_" in root
$cache=new CACHE($folder);
...... ........................... // after that.. the rest of the page/scripts

//showing the content 
? ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

b) server side caching

$cache=new CACHE($folder);
$cache->setCacheType(1); //server side caching

c) client side (browser) caching

$cache=new CACHE($folder);
$cache->setCacheType(2); //client side caching

d) both (server and client browser) side caching

$cache=new CACHE($folder);
$cache->setCacheType(3); //both side caching

e) simple client side cache

$cache=new CACHE($folder,1);

f) logged user both side cache

$cache=new CACHE($folder,2, $_COOKIE['user']); // $_COOKIE['user'] is just an example

g) changing the default settings (in the cache.php file):

private $root=""; // path to the local folder, YOU NEED WRITING PERMISSIONS (chmod 666 or 777)
private $server__cache_time=300; // how long a file will remain cached on browser ( seconds )
private $client__cache_time=150; //how long a file will remain cached on browser ( seconds )
private $cache_type=2; // 0 = no cache , 1 = server side cache, 2 = client side (browser) cache, 3 = both side cache
private $attached_value=""; //useful to COOKIE or SESSION values (for example it may be used for logged users )
private $page;
public $file_name; // the cache file name on server
public $full_file_name; //full file path and name on local server
public $need_update=false; //if true then the content will be saved locally in the path (full_file_name)
public $file_extension="html"; // useful to check the cache content faster

i) extra basic usage
$cache=new CACHE($_SERVER['DOCUMENT_ROOT']."/cache_",2);
//within these lines of code  all caching is performed no matter the page html content is loaded after 

j) all methods

$cache=new CACHE();
$cache->setRoot($folder); // the cached files will be saved locally (if server side caching) here
$cache->setCacheType(3); //both side caching
$cache->setClientCacheTime(100); //the page will be kept in user's browser 100 s, the page will be same within this interval
$cache->setServerCacheTime(300); // the page will be kept on the server for ALL users 300 s, and will not be generated dinamically within that intarval
$cache->setCacheTime(225); //both server and local caching interval will be set to 225 seconds, in this case will overwritten the previous 2 calls (setClientCacheTime, setServerCacheTime)
$cache->setFileExtension("html"); // this will save cached files as html and it will make it easier to check the saved files
$cache->startCache(); // it will start caching process

Cache type table
Cache Type Value 	Cache action
0	No cache
1	Server side cache
2	Client side cache
3	Both sides cache

This  class and Manual has been  created by Molnar Raul ( 
For any question and help you may write there or on
You have full rights to change.. use.. sell.. donate some (to the Paypal account .
Good luck and enjoy !

For more information send a message to info at phpclasses dot org.