PHP Classes

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: 10 years ago
Size: 4,163 bytes
 

Contents

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 <?php $folder=$_SERVER['DOCUMENT_ROOT']."/cache_"; // in this case i created the folder "cache_" in root $cache=new CACHE($folder); $cache->startCache(); ...... ........................... // after that.. the rest of the page/scripts //showing the content ? ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ........................... b) server side caching $folder=$_SERVER['DOCUMENT_ROOT']."/cache_"; $cache=new CACHE($folder); $cache->setCacheType(1); //server side caching $cache->startCache(); c) client side (browser) caching $folder=$_SERVER['DOCUMENT_ROOT']."/cache_"; $cache=new CACHE($folder); $cache->setCacheType(2); //client side caching $cache->startCache(); d) both (server and client browser) side caching $folder=$_SERVER['DOCUMENT_ROOT']."/cache_"; $cache=new CACHE($folder); $cache->setCacheType(3); //both side caching $cache->startCache(); e) simple client side cache $folder=$_SERVER['DOCUMENT_ROOT']."/cache_"; $cache=new CACHE($folder,1); $cache->startCache(); f) logged user both side cache $folder=$_SERVER['DOCUMENT_ROOT']."/cache_"; $cache=new CACHE($folder,2, $_COOKIE['user']); // $_COOKIE['user'] is just an example $cache->startCache(); 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); $cache->startCache(); //within these lines of code all caching is performed no matter the page html content is loaded after j) all methods $folder=$_SERVER['DOCUMENT_ROOT']."/cache_"; $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 (molnarraul@yahoo.com). For any question and help you may write there or on raul@webstorm.ro You have full rights to change.. use.. sell.. donate some (to the Paypal account rm@webstorm.ro) . Good luck and enjoy !