PHP Metameric Cache

Buy from CodeCanyon


Introduction

PHP Metameric Cache is a disk based cache mechanism that lets you create cache for selected parts of PHP page or PHP website quickly and easily. It does not depend on URL structure of your website. You can store each cached part with a unique name and then retrieve it or delete it on rerquirement. This cache will create segmented cache for your web application for those parts that require heavy server processing. Use this to speed up your website, boost performance and loading time.


PHP Metameric Cache Features


Explanation

This script is for those who do not like 'full page caching' or 'full website caching'. Exclude login or user areas completely from caching. Take selected parts, from website or from PHP page - define their names and cahce those parts individually. This cache will get output from those parts and store them with their unique names in cache folder. Next time when the page loads, if those segments are stored in cache, will be displayed from cache and their real PHP code that generated those parts will not be executed. Real PHP code execution including database requests will be skipped and its already stored output will be displayed. You can cache as many parts of a page or a website as you like. This gives you full control over your website content. You can decide from where, what and how much to cache. Its simple and easy to use.


Implementation / Usage

Its a 4 step process to cache any part of webpage

--cachePARTname--
--start cache--
Code or Content no 1
--end cache--

--cachePARTname--
--start cache--
Code or Content no 2
--end cache--

more content of webpage

--cachePARTname--
--start cache--
Code or Content no 3
--end cache--

Exact Implementation

< ? p h p 
$filename="fast-tiger";
include("start-cache.php");
if($cached!='yes') { ? >

Once upon a time there was a tiger in a jungle who was very very fast.

< ? p h p } include("end-cache.php");
? >

This will create a cache file named as cache_fast-tiger and store the data "Once upon a time there was a tiger in a jungle who was very very fast." in it

.

Custom Caching Time for Individual Section

Some areas of website do not update often, its good idea to let them remain cached for longer time than other important areas. You can specify custom time for caching easily. For above example default time for individual cached pages is 12 hours after creation, unless they are deleted manually. If you like to set custom time then use the code like below:

< ? p h p 
$filename="fast-tiger";
$cachetime=48 * 3600; //48 hours
include("start-cache.php");
if($cached!='yes') { ? >

Once upon a time there was a tiger in a jungle who was very very fast.

< ? p h p } include("end-cache.php");
? >

Only addition is $cachetime=48 * 3600; - right after we give name to that part of code. After using it, cache time for only this part will be changed. $filename is necessary and $cachetime is optional. If you do not use custom time, script will use default time that is 12 hours. You can change the default time for cache validity from main script file.

12 * 3600 = 12 hours
24 * 3600 = 24 hours
48 * 3600 = 48 hours


© 2013 TechMynd