[TomatoCart] – Cache home page to speed up loading your store

When a customer accesses the home page of your online store, the system needs to load numerous resources which will impact the speed to load your home page. In this article, I will show a cache solution to speed up loading the home page both for glassgray and bootstrap template.

Snip20150823_1

After caching the dynamic content of home page, the wall time is only 89007 ms. It means that the web server just spend 0.08 second to load your home page. It’s really fast. Now, i will teach you how to apply the changes for shop template.

— For store using the default glass gray template

Step 1. Open index.php under template > glass_gray fold to edit it.

Step 2. Find following code snippet:

<div id="slideShow">

Step 3. Add following code before it:

<?php 
 $key_homecontent = 'homecontent.' . $osC_Template->getCode() . '.' . $osC_Language->getCode();
 if ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' && $osC_Cache->read($key_homecontent) === false) {
 $osC_Cache->startBuffer();
 }
?>

Step 4. Find following code snippet:

    unset($content_left);
    unset($content_right);
  ?>
</div>

Step 5. Add following code after it:

<?php 
 if ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index') {
 $osC_Cache->stopBuffer();
 echo $osC_Cache->getCache();
 }
?>

— For store using the bootstrap template

Step1. Open index.php under templates > bootstrap fold to edit.

Step 2. Find following code:

<!--  slideshow  -->
<?php 
    $slideshow = $osC_Template->getContentGroup('slideshow');
    if (!empty($slideshow)) {
?>

Step 3. Add following code before it:

<?php 
 $key_homecontent = 'homecontent.' . $osC_Template->getCode() . '.' . $osC_Language->getCode();
 if ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' && $osC_Cache->read($key_homecontent) === false) {
 $osC_Cache->startBuffer();
 }
?>

Step 4. Find following code:

<?php 
  if ($osC_Template->hasPageFooter()) {
?>

Step 5. Add following code before it:

<?php 
 if ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index') {
 $osC_Cache->stopBuffer();
 echo $osC_Cache->getCache();
 }
?>

Final word

If you modify the content of home page, don’t forget to clear the cached file for home page under admin panel > Tools > Cache control.

Snip20150823_2

 

 

Tags: , , , , , , , , , , | Posted under TomatoCart | RSS 2.0

Author Spotlight

Jack Yin

TomatoCart Developer & Co Founder - Arvixe Web Hosting / TomatoCart Community Liaison

One Comment on [TomatoCart] – Cache home page to speed up loading your store

  1. Dartco says:

    Jack, this feature doesn’t work in my store. I get only part of cached page. Didn’t checked more but maybe you have some ideas

Leave a Reply

Your email address will not be published. Required fields are marked *