Speed up CRE Loaded with cache

invisibleSHIELD: 250x250 Square Pop-Up Hot Product

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,true);
# 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.

8 Responses to “Speed up CRE Loaded with cache”

  1. hello

    the following codes did not work for me in cre loaded 6.4

    get_cache(‘GLOBAL’);
    ?>

    But if you change

    include(DIR_WS_CLASSES . ‘cache.class.php’);

    to

    include(‘includes/classes/cache.class.php’);

    works fine for me.

    Thanks

  2. include(DIR_WS_CLASSES . ‘cache.class.php’); and include(‘includes/classes/cache.class.php’); must result identical. Please check if DIR_WS_CLASSES is properly configured in includes/configure.php.

  3. @wasimasif

    Yes i checked the configure file in includes it is configured properly

    “define(‘DIR_WS_CLASSES’, DIR_WS_INCLUDES . ‘classes/’);

    so if i used

    include(‘includes/classes/cache.class.php’); and result are identical

    so it okay to use full path?
    and i tested the site with full path and it did speed up.

    thanks

  4. Yeh its also ok to use paths like this. Good to know its working great for you.

  5. I want to thank the blogger very much not only for this post but also for his all previous efforts. I found this to be extremely interesting. I will be coming back to this for more information.

  6. I cannot get past a syntax error. I am running CRE 6.4

    Parse error: syntax error, unexpected T_CLASS in /path/to/includes/runtime/applicationtop/cache_applicationtop_bottom.php on line 5

    any ideas?

  7. Not sure that this is a php5 issue? Changing the single quotes to double quotes resolved the error on line 5 as described above.

  8. No its not PHP5 issue. The single and double quote characters are replace with similar looking character by wordpress. When you copy paste code php generates error. The easy way to fix is whenever you copy from online web site replace single quote or double quote like characters with actual quotes.

Leave a Reply