Adding Cache ability in CRE Loaded PCI 6.4
Cache have become an important tool for increasing performance of a website. In this post we will install a famous osCommerce contribution to our CRE Loaded PCI 6.4 for cache.
The contribution is called osC Advanced Cache Class. The contribution will enable us to cache just about every thing like large arrays, data, html, even executable PHP code. More details of the contribution can be found here.
Here we will only install this contribution on cre loaded 6.4 we will use it later some where. For the possible uses please see contribution home page, referred above.
We will be installing it on Pro version and I hope the process will be same for other cre loaded versions. We will use Runtime Code Inclusion (RCI) feature of Cre loaded, to minimize chances of losing our changes during future upgrades. For RCI details refer to cre loaded.
Step One: downloading the contribution
Download the contribution from this page and extract it to some folder. The code includes an install script but please don’t use it as it is made for oscommerce not cre loaded.
Step Two: Adding class file
Copy osC-Cache/osC-Cache/upload/includes/classes/cache.class.php file to your installation of your cre loaded. The file should be copied to /includes/classes/ folder of your installation.
Step Three: Database Changes
You will need to add a new table in you database. Create a new table by executing the following query.
CREATE TABLE cache (
cache_id varchar(32) NOT NULL default '',
cache_language_id tinyint(1) NOT NULL default '0',
cache_name varchar(255) NOT NULL default '',
cache_data mediumtext NOT NULL,
cache_global tinyint(1) NOT NULL default '1',
cache_gzip tinyint(1) NOT NULL default '1',
cache_method varchar(20) NOT NULL default 'RETURN',
cache_date datetime NOT NULL default '0000-00-00 00:00:00',
cache_expires datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (cache_id,cache_language_id),
KEY cache_id (cache_id),
KEY cache_language_id (cache_language_id),
KEY cache_global (cache_global)
) TYPE=MyISAM;
Step Four: Implement cache class using RCI
Now create a new empty file named cache_applicationtop_bottom.php in folder includes/runtime/applicationtop/ of your cre loaded installation. Now open the new file and put following code in the file cache_applicationtop_bottom.php
<?php
global $cache, $languages_id;
# include the cache class
include(DIR_WS_CLASSES . ‘cache.class.php’);
$cache = new cache($languages_id);
# Get the cache – no parameters will get all GLOBAL cache entries for this language
$cache->get_cache(‘GLOBAL’);
?>
After saving the file try browsing your site, if you have done all steps properly you should not have any problems with it. If you see any problem like blank page is displayed or any thing else please make sure that you followed all steps properly.
May be in some other post we will see how we can use this cache contribution with cre loaded and get maximum advantages of cache.
Perfect!