Home > CRE Loaded > Speed up CRE Loaded with cache

Speed up CRE Loaded with cache

December 2nd, 2009 Leave a comment Go to comments

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.

Categories: CRE Loaded Tags:
  1. January 1st, 2010 at 19:52 | #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. wasimasif
    January 3rd, 2010 at 04:59 | #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. PJ
    January 4th, 2010 at 02:11 | #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. wasimasif
    January 4th, 2010 at 14:13 | #4

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

  5. toronto
    February 27th, 2010 at 21:19 | #5

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

  1. No trackbacks yet.