Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

234BS - Speed Improvements


Recommended Posts

@@Gyakutsuki

 

Hi Loic

 

Thanks for your response, however the problem still exists.

I don't have anything showing under admin>config.I have checked that both files in the download  have been uploaded and  are in their correct place, and the addition to DB is in fact under configuration.(my site is probably moderately modified)

I was wanting to see if this addon made any dif to page load times  GTMetrix shows at 96/81

 

I did find the following in the error log, don't know whether it may help or hinder.

[16-Jun-2016 08:42:56 Pacific/Auckland] PHP Warning:  require(includes/classes/osc_template.php): failed to open stream: No such file or directory in /home/XXXXX/public_html/includes/application_top.php on line 465
[16-Jun-2016 08:42:56 Pacific/Auckland] PHP Warning:  require(includes/classes/osc_template.php): failed to open stream: No such file or directory in /home/XXXXX/public_html/includes/application_top.php on line 465
[

Cheers

Grandpa

Link to comment
Share on other sites

@

Compare the class with this:

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2014 osCommerce

  Released under the GNU General Public License
*/

  class oscTemplate {
    var $_title;
    var $_blocks = array();
    var $_content = array();
    var $_grid_container_width = 12;
    var $_grid_content_width = BOOTSTRAP_CONTENT;
    var $_grid_column_width = 0; // deprecated
    var $_data = array();

    function __constrcut() {
      $this->_title = TITLE;
    }

    function setGridContainerWidth($width) {
      $this->_grid_container_width = $width;
    }

    function getGridContainerWidth() {
      return $this->_grid_container_width;
    }

    function setGridContentWidth($width) {
      $this->_grid_content_width = $width;
    }

    function getGridContentWidth() {
      return $this->_grid_content_width;
    }

    function setGridColumnWidth($width) {
      $this->_grid_column_width = $width;
    }

    function getGridColumnWidth() {
      return (12 - BOOTSTRAP_CONTENT) / 2;
    }

    function setTitle($title) {
      $this->_title = $title;
    }

    function getTitle() {
      return $this->_title;
    }

    function addBlock($block, $group) {
      $this->_blocks[$group][] = $block;
    }

    function hasBlocks($group) {
      return (isset($this->_blocks[$group]) && !empty($this->_blocks[$group]));
    }

    function getBlocks($group) {
/*
      if ($this->hasBlocks($group)) {
        return implode("\n", $this->_blocks[$group]);
      }
*/
      if ($this->hasBlocks($group))  {

        if (CONFIGURATION_MINIFY_TEMPLATE == 'false') {
          $getblock = implode("\n", $this->_blocks[$group]);
        } else {
          require_once(DIR_WS_CLASSES . '/MinifyCode.php');

          $minifyCode = new MinifyCode();
          $str = implode("\n", $this->_blocks[$group]);
          $getblock = $minifyCode->minifyHtml($str);
        }
        return $getblock;
      }
    }

    function buildBlocks() {
      global $language;

      if ( defined('TEMPLATE_BLOCK_GROUPS') && tep_not_null(TEMPLATE_BLOCK_GROUPS) ) {
        $tbgroups_array = explode(';', TEMPLATE_BLOCK_GROUPS);

        foreach ($tbgroups_array as $group) {
          $module_key = 'MODULE_' . strtoupper($group) . '_INSTALLED';

          if ( defined($module_key) && tep_not_null(constant($module_key)) ) {
            $modules_array = explode(';', constant($module_key));

            foreach ( $modules_array as $module ) {
              $class = basename($module, '.php');

              if ( !class_exists($class) ) {
                if ( file_exists(DIR_WS_LANGUAGES . $language . '/modules/' . $group . '/' . $module) ) {
                  include(DIR_WS_LANGUAGES . $language . '/modules/' . $group . '/' . $module);
                }

                if ( file_exists(DIR_WS_MODULES . $group . '/' . $module) ) {
                  include(DIR_WS_MODULES . $group . '/' . $module);
                }
              }

              if ( class_exists($class) ) {
                $mb = new $class();

                if ( $mb->isEnabled() ) {
                  $mb->execute();
                }
              }
            }
          }
        }
      }
    }

    function addContent($content, $group) {
      $this->_content[$group][] = $content;
    }

    function hasContent($group) {
      return (isset($this->_content[$group]) && !empty($this->_content[$group]));
    }

    function getContent($group) {
      global $language;

      if ( !class_exists('tp_' . $group) && file_exists(DIR_WS_MODULES . 'pages/tp_' . $group . '.php') ) {
        include(DIR_WS_MODULES . 'pages/tp_' . $group . '.php');
      }

      if ( class_exists('tp_' . $group) ) {
        $template_page_class = 'tp_' . $group;
        $template_page = new $template_page_class();
        $template_page->prepare();
      }

      foreach ( $this->getContentModules($group) as $module ) {
        if ( !class_exists($module) ) {
          if ( file_exists(DIR_WS_MODULES . 'content/' . $group . '/' . $module . '.php') ) {
            if ( file_exists(DIR_WS_LANGUAGES . $language . '/modules/content/' . $group . '/' . $module . '.php') ) {
              include(DIR_WS_LANGUAGES . $language . '/modules/content/' . $group . '/' . $module . '.php');
            }

            include(DIR_WS_MODULES . 'content/' . $group . '/' . $module . '.php');
          }
        }

        if ( class_exists($module) ) {
          $mb = new $module();

          if ( $mb->isEnabled() ) {
            $mb->execute();
          }
        }
      }

      if ( class_exists('tp_' . $group) ) {
        $template_page->build();
      }


      if ($this->hasContent($group))  {

        if (CONFIGURATION_MINIFY_TEMPLATE == 'false') {
          $contentblock = implode("\n", $this->_content[$group]);
        } else {
          require_once(DIR_WS_CLASSES . '/MinifyCode.php');

          $minifyCode = new MinifyCode();
          $str = implode("\n", $this->_content[$group]);
          $contentblock = $minifyCode->minifyHtml($str);
        }
        return $contentblock;
      }

    }

    function getContentModules($group) {
      $result = array();

      foreach ( explode(';', MODULE_CONTENT_INSTALLED) as $m ) {
        $module = explode('/', $m, 2);

        if ( $module[0] == $group ) {
          $result[] = $module[1];
        }
      }

      return $result;
    }
  }

look : My configuration / mystore . You must see this element : Do you want to minify the html code in the shop catalog

If not insert the request below.

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Do you want to minify the html code in the shop catalog', 'CONFIGURATION_MINIFY_TEMPLATE', 'false', 'Minify the HTML code to improve site speed' , '1', '5', 'osc_cfg_select_option(array(\'true\', \'false\'), ', now());

Don't forget to include the class files inside class directory.

 

After you can test and activate the option or not.


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

@@Gyakutsuki

Hi Loic

 

Making progress.

Have installed but get this message when I try to Edit in My Store

Fatal error: Call to undefined function osc_cfg_select_option() in /home/XXXX/public_html/ADMIN/configuration.php(106) : eval()'d code on line 1

Not sure what .."Don't forget to include the class files inside class directory." means.

 

Cheers

Grandp

Link to comment
Share on other sites

ok, change osc_cfg_select_option by tep_cfg_select_option


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

Google ad tag is a :poop: for speed..

 

//www.googleadservices.com/pagead/conversion.js

Mobile site page speed decrease approx 20% by google codes. Assyncron mode dosnt work.

 

Any .js scripts (especially those from external src) will slow down the page a lot.

As a test I just installed all the Social Bookmark modules, and this added over two seconds to the product page load!

Link to comment
Share on other sites

@@grandpaj

Speed increase wont work without file cache but we have less problems.

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

Any .js scripts (especially those from external src) will slow down the page a lot.

As a test I just installed all the Social Bookmark modules, and this added over two seconds to the product page load!

Any social feature loding time is not as critical but google tracking codes is awfull. Social buttons could be loading with ajax codes or asyncr mode where one like button is not as important.

CDN loading could be the same when no response and breaks all scripts. Async loading is critical for page speed.

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

@Gergely

 

There a cache system for this.

 

create a directory in Cache/Files inside icludes/work

 

 

include theses elements in includes/functions/general at the end.

    function getUrl () {
      if (!isset($_SERVER['REQUEST_URI'])) {
        $url = $_SERVER['REQUEST_URI'];
      } else {
        $url = $_SERVER['SCRIPT_NAME'];
        $url .= (!empty($_SERVER['QUERY_STRING']))? '?' . $_SERVER[ 'QUERY_STRING' ] : '';

      }
      return $url;
    }

//getUrl gets the queried page with query string
    function cache ($buffer) { //page's content is $buffer

      $url = $this->getUrl();
      $filename = md5($url) . '.cache';
      $data = time() . '¦' . $buffer;
      $filew = fopen(DIR_FS_CATALOG . 'includes/work/Cache/Files/' . $filename, 'w');
      fwrite($filew, $data);
      fclose($filew);
      return $buffer;
    }

    function getDisplayCache() {

      $url = $this->getUrl();
      $filename = md5($url) . '.cache';

      if (!file_exists(DIR_FS_CATALOG . 'includes/work/Cache/Files/' . $filename)) {
        return false;
      }

      $filer = fopen(DIR_FS_CATALOG . 'includes/work/Cache/Files/' . $filename, 'r');

      $data = fread($filer, filesize(DIR_FS_CATALOG . 'includes/work/Cache/Files/' . $filename));
      fclose($filer);
      $content = explode('¦', $data, 2);
      if (count($content)!= 2 OR !is_numeric($content['0'])) {
        return false;
      }
      if (time()-(100) > $content['0']) { // 100 is the cache time here!!!
        return false;
      }
      echo $content['1'];
      die();
    }

Now in template_bootom

 

at the end include this


// Display cache (if any)
getDisplayCache(); // if it is displayed, die function will end the program here.

// if no cache, callback cache
ob_start ('cache');


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

@@Gyakutsuki

Hi Loic

template_bottom.php when the above code is included in template_bottom.php should it look like this

<?php echo $oscTemplate->getBlocks('footer_scripts'); ?>
// Display cache (if any)
getDisplayCache(); // if it is displayed, die function will end the program here.

// if no cache, callback cache
ob_start ('cache');
</body>
</html>

Cheers

Grandpa

Link to comment
Share on other sites

no like this

<?php
// Display cache (if any)
getDisplayCache(); // if it is displayed, die function will end the program here.

// if no cache, callback cache
 ob_start ('cache');
?>

It's for only test.

 

Look also in ftp the if the cache is created or not


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

  • 4 weeks later...

The only pb with my contribution is some script can doesn't work and they need to be improve and you need to do becarefull on that.


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

@@Gyakutsuki

 

Hi Loic

 

Just reviviting this.

 

Where on earth do I find

ok, change osc_cfg_select_option by tep_cfg_select_option (post #31)

please.

 

Can't for the life of me find it.

 

Cheers

 

Grandp

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

Hi,

Just a question, about the HT access part. I have the following :

Htaccess in root with redirect to a directory where the shop is. 

in the catalog directory alos a htaccess file. 

In which of the files is it best to put the optimization in.

Greetings, Anne

Link to comment
Share on other sites

23 hours ago, DjViper said:

Hi,

Just a question, about the HT access part. I have the following :

Htaccess in root with redirect to a directory where the shop is. 

in the catalog directory alos a htaccess file. 

In which of the files is it best to put the optimization in.

Greetings, Anne

Hi Anne, htaccess works hierarchically. You can put it in either but if the top one it needs to be before the redirect.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

  • 1 year later...

hi,

I applied Gergely's solution and tested the same product_info page before and after. The one part I did not use from the solution, was the code changed for ht_grid_list_view.php file. For some reason the last line was causing an error in the application I am using and I decided not to use that particular change. I also used my own .htaccess DEFLATE script. The GTMetrix results are in the screenshot below.

speed-improvements.thumb.png.7872d6f4ab04e9425c23878d4a742f50.png

Shaving off two requests and 100+ms is Great!

However, after the changes, the page loads where not smooth. I cleared the browser cache and every time I'd reload a page or load a new one, it would flash an "un-formatted" version of the page for like a split second and that made page-loading jumpy.

After playing around for a while in trying to get an ideal order of resources being loaded to eliminate that jumpiness, I ended up reverting the changes for the /includes/template_top.php file, but kept some of the other ones.

Just wanted to thank you for addressing the page loading speed issue and for providing a viable working solution. The test results prove that it works!

 

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...