Jump to content

Increase site speed


DARKF3D3

Recommended Posts

This is something that has been greatly improved in PrestaShop v1.4. It adds the following to the .htaccess file:


   ExpiresActive On
   ExpiresByType image/gif "access plus 1 month"
   ExpiresByType image/jpeg "access plus 1 month"
   ExpiresByType image/png "access plus 1 month"
   ExpiresByType text/css "access plus 1 week"
   ExpiresByType text/javascript "access plus 1 week"
   ExpiresByType application/javascript "access plus 1 week"
   ExpiresByType application/x-javascript "access plus 1 week"
   ExpiresByType image/x-icon "access plus 1 year"


FileETag INode MTime Size

   AddOutputFilterByType DEFLATE text/html
   AddOutputFilterByType DEFLATE text/css
   AddOutputFilterByType DEFLATE text/javascript
   AddOutputFilterByType DEFLATE application/javascript
   AddOutputFilterByType DEFLATE application/x-javascript



This enables compression and caching. It also has the option to combine, compress and cache CSS and Javascript. In PrestaShop v1.3, you must do that manually, which is very difficult.

Link to comment
Share on other sites

From the PrestaShop v1.4 Performance Guide I'm working on:

A customer’s location can have an impact on response times. A content delivery network (CDN) is a collection of web servers distributed across multiple locations to deliver content more efficiently to users. When a customer’s browser requests a file, their browser will download it from the closest available server, which will be much faster than if it was downloaded only from the country where your website is hosted. It also saves bandwidth on your website, since the file is downloaded from the CDN instead of your website. Customers will also save bandwidth if the file is a common library like jQuery that has already been downloaded for another website, since the file will be read from the browser’s cache instead of re-downloaded.

Google has a CDN available with many common libraries. For example, the URL for jQuery v1.4.4 is https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js.

Link to comment
Share on other sites

the parameters you see there are all secondary. Firstly you have to optimize server performance - php scripts and database requests.

I look at your site - all static elements are loaded without delay. And they are cached by browser so you should not keep in mind compressing and minifiing.
But category and product pages take from 1.4s to load. I had the same issue on my site.
The problem is how Prestashop handles the database and generates output html.
It makes a lot of duplicate requests and some hard requests to the database. Smarty is rather hard too.

This is a common problem for the sites having rich dynamic content.

If products list in categories and information on product pages are slow changing (for instance once a day or two times a day) you may cache it on the hard disk of your server (with Cache_Lite) or on another server (with memcache). If your visitor makes request to the cached data your server gets it from cache and does not deal with php and mySQL
It is most likely that Cache_Lite is enabled on your host. Ask your hosting provider.

To use it you need to modify some php files. I have seen that some modules in Prestashop have elements of caching but they are not working properly.

If you need help write me.

Link to comment
Share on other sites

Smarty caching can be used instead Cache_Lite
http://www.prestashop.com/forums/viewreply/311861/
This method used in 1.4 version:

Tools::enableCache();
if (!$this->isCached('blockcategories.tpl', $smartyCacheId))
{
...
}
$display = $this->display(__FILE__, 'blockcategories.tpl', $smartyCacheId);
Tools::restoreCacheSettings();
return $display;



Cache size for 1 category = category page size * laguage count * sorts methods count * sort direction count (2)

For increase client side speed merge and compress js and css files with YUI Compressor, use css sprites for background images. Compress output html code with smarty postfilter (but I use smarty compilled templates compression).

For automatic site accelerate you may use http://code.google.com/p/web-optimizator/

Link to comment
Share on other sites

This site use web-optimizator.

Unpack web-optimizator from http://code.google.com/p/web-optimizator/ to your website root
Add to begining of header.php

require('/your-website-root/web-optimizer/web.optimizer.php');


Add to end of footer.php

$web_optimizer->finish();


Add write permissions to /web-optimizer/ directory
Open http://your-website/web-optimizer/index.php and install changes to index.php and .htaccess

In addition to 1.4 functions this script add CSS Sprites, data:URI and Coral CDN using. Maybe developers are using some ideas from this script to increase prestashop perfomance.

36891_AxoD3gBUIl1f1rYqN3Z1_t

Link to comment
Share on other sites

  • 3 weeks later...

A word of caution: sometimes, especially with shared hosting, you can slow down your site by enabling certain technologies intended to speed your site up. Using compression on pages can be one of them as this is CPU intensive and when used on a busy server can result in the time spent compressing being longer than the reduction in time to transfer the now smaller files.

Optimisations like these are actually very hard to analyze properly unless you have the equipment isolated in a test environment and are able to accurately measure the improvements made. A score of 70+ out of 100 wouldn't seem all that bad to me anyway.

I would urge you to track the performance of your site over time, just to make sure that you aren;t slowing down your site in pursuit of a "perfect" performance score!

Paul

Link to comment
Share on other sites

I'm working with 1.4 via the SVN right now and I have to say that once I'd migrated the theme to 1.4 I then as a test:

- enabled smarty 3,
- turned on the smarty optimisations
- enabled the first 4 CCC optimisations
- set up 3 cdn domains

The increase in performance was noticeably significant though -- but in the front office only. The Back Office is less important, but it would be nice if the back office was a little quicker in places, but it's lower priority :)

The problem with some of these performance tools like Yahoo's YSlow and Google's Page speed is that they in some cases give conflicting advice, because there really is no one single ideal solution for every site. As an example YSlow will recommend a CDN, but Google Page Speed will see the extra DNS lookups and recommend you minimise them.....

You have to be careful you don't end up optimising an arbitrary score (as calculated by a performance tool) and as a result DE-optimise your site :D

There are parallels with running "SEO analysis" tools on pages and making silly changes to please a bit of software; for no real gain.

Paul

Link to comment
Share on other sites

For css and js files your may use static compression http://www.prestashop.com/forums/viewthread/91306/development/static_compression_for_ccc

For automated css sprites creation see this code http://web-optimizator.googlecode.com/svn/trunk/libs/php/css.sprites.optimize.php

HTML minification option increase page generation speed. Your may use this option as smarty prefilter for minificate template before compiling in php code.

For prestashop 1.3 unzip prefilter.tws.php to tools/smarty/plugins and add to config/smarty.config.inc.php

$smarty->load_filter('pre','tws');

prefilter.tws.php.zip

Link to comment
Share on other sites

  • 2 weeks later...

For using html and inline js compression as prefilter in version 1.4 in config/smarty.config.inc.php replace

   if (Configuration::get('PS_HTML_THEME_COMPRESSION'))
       $smarty->registerFilter('output', 'smartyMinifyHTML');
   if (Configuration::get('PS_JS_HTML_THEME_COMPRESSION'))
       $smarty->registerFilter('output', 'smartyPackJSinHTML');


with

   if (Configuration::get('PS_HTML_THEME_COMPRESSION'))
       $smarty->registerFilter('pre', 'smartyMinifyHTML');
   if (Configuration::get('PS_JS_HTML_THEME_COMPRESSION'))
       $smarty->registerFilter('pre', 'smartyPackJSinHTML');


In tools/js_minify/jsmin.php replace

           if (ord($this->a) <= self::ORD_LF) {
           throw new JSMinException('Unterminated string literal.');
           }


with

           if (ord($this->a) <= self::ORD_LF) {
           break;
           }


and after

           case ' ':
             if ($this->isAlphaNum($this->a)) {
               $this->action(1);
               break;
             }


delete

             $this->action(3);
             break;

Link to comment
Share on other sites

This is something that has been greatly improved in PrestaShop v1.4. It adds the following to the .htaccess file:


   ExpiresActive On
   ExpiresByType image/gif "access plus 1 month"
   ExpiresByType image/jpeg "access plus 1 month"
   ExpiresByType image/png "access plus 1 month"
   ExpiresByType text/css "access plus 1 week"
   ExpiresByType text/javascript "access plus 1 week"
   ExpiresByType application/javascript "access plus 1 week"
   ExpiresByType application/x-javascript "access plus 1 week"
   ExpiresByType image/x-icon "access plus 1 year"


FileETag INode MTime Size

   AddOutputFilterByType DEFLATE text/html
   AddOutputFilterByType DEFLATE text/css
   AddOutputFilterByType DEFLATE text/javascript
   AddOutputFilterByType DEFLATE application/javascript
   AddOutputFilterByType DEFLATE application/x-javascript



This enables compression and caching. It also has the option to combine, compress and cache CSS and Javascript. In PrestaShop v1.3, you must do that manually, which is very difficult.



This was very useful for me and I managed to speed up my download times noticeably. However, I have another problem which is probably very simple, but I can't seem to find the remedy for.

Now that my text & images are cached, I can't edit them and can't find a way to clear the cache so that changes show up.

Any pointers?

Thanks again for sharing the above.

Iain
Link to comment
Share on other sites

For css and js files your may use static compression http://www.prestashop.com/forums/viewthread/91306/development/static_compression_for_ccc

For automated css sprites creation see this code http://web-optimizator.googlecode.com/svn/trunk/libs/php/css.sprites.optimize.php

HTML minification option increase page generation speed. Your may use this option as smarty prefilter for minificate template before compiling in php code.

For prestashop 1.3 unzip prefilter.tws.php to tools/smarty/plugins and add to config/smarty.config.inc.php
$smarty->load_filter('pre','tws');



thank you for share this plugin for 1.3 it's for jsminify.

is there any plugin for css and php minify ?
Link to comment
Share on other sites

  • 3 months later...
This site use web-optimizator.

Unpack web-optimizator from http://code.google.com/p/web-optimizator/ to your website root
Add to begining of header.php
require('/your-website-root/web-optimizer/web.optimizer.php');


Add to end of footer.php

$web_optimizer->finish();


Add write permissions to /web-optimizer/ directory
Open http://your-website/web-optimizer/index.php and install changes to index.php and .htaccess

In addition to 1.4 functions this script add CSS Sprites, data:URI and Coral CDN using. Maybe developers are using some ideas from this script to increase prestashop perfomance.



Hey sors I have a quich question for you.

Is it really a must to add these two codes in the header.php and footer.php ?
I am asking because the software installs these codes in the start and end
of the index.php file.

Tnx
Link to comment
Share on other sites

  • 1 year later...

This is something that has been greatly improved in PrestaShop v1.4. It adds the following to the .htaccess file:

 


ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"


FileETag INode MTime Size

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

 

This enables compression and caching. It also has the option to combine, compress and cache CSS and Javascript. In PrestaShop v1.3, you must do that manually, which is very difficult.

 

Hey Rocky

Can u tell me how to do it in Prestashop 1.3.1.1

Plus If i create .htaccess so I can create more items field and upload picture.. its doesnt affected...coz sometime its show blank pages

Link to comment
Share on other sites

there should be an.htaccess file located in the root of your store. just add those lines to the end of the .htaccess file.

 

Hey

thnx for reply I tried this but there is error even I talked with my Host provide to On ExpiresActive On

He said it is On but still I have error

 

"

Internal Server Error

 

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

"

Link to comment
Share on other sites

and did you review the server error log as the error message suggests?

Thnx for reply I done

But my client says to me its really slow even now I have only few pics and categories

 

successfully but my speed is 76/100 on webpagetest

but

developer.google show That 58/100

even after this is show u didnt define image

"The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

what does mean ...?

kindly reply me

www.idisplay.se

Link to comment
Share on other sites

your TTFB (time to first byte) is very long (3-4 seconds).

 

you also have 5 images that took more than 2 seconds each to download.

URL: http://www.idisplay.se/modules/slideric/en0.jpg

URL: http://www.idisplay.se/modules/slideric/en1.jpg

URL: http://www.idisplay.se/modules/slideric/en2.jpg

URL: http://www.idisplay.se/modules/slideric/en3.jpg

URL: http://www.idisplay.se/img/favicon.ico

Link to comment
Share on other sites

  • 1 month later...

For css and js files your may use static compression http://www.prestasho...ression_for_ccc

 

For automated css sprites creation see this code http://web-optimizat...es.optimize.php

 

HTML minification option increase page generation speed. Your may use this option as smarty prefilter for minificate template before compiling in php code.

 

For prestashop 1.3 unzip prefilter.tws.php to tools/smarty/plugins and add to config/smarty.config.inc.php

$smarty->load_filter('pre','tws');

 

In what line i have to put that code $smarty->load_filter('pre','tws'); please?

Link to comment
Share on other sites

Great stuff. Need help thou. I'm running 1.4.7 and want to use it all. I have all the out of the box compression on.

 

where do I put: http://web-optimizator.googlecode.com/svn/trunk/libs/php/css.sprites.optimize.php

 

and where do I put prefilter.tws.php.zip ?

 

Should I also follow this http://www.prestashop.com/forums/topic/91306-static-compression-for-ccc/ and http://www.prestashop.com/forums/topic/91306-static-compression-for-ccc/ or did 1.4.7 have it sorted?

Link to comment
Share on other sites

  • 4 months later...
  • 3 weeks later...
  • 8 months later...

I searched the forum for YUI Compressor, Closure Tools, Minify, yuglify and came over this thread. It is one of the rare in this forum dealing with these keywords.

 

Since it of utter importance having a speedy shop I assume all these tools are of not interest when dealing with Prestashop or Prestashop does better when all CCC are on.

 

Anyway our shop runs as a shared webhost on a Hetzner server and I had to reckon that it runs measureably (common tools) and subjectively more snappy and faster with all CCC off and Apache optimizations off.

 

However, I still wonder if our shop could benefit from compressed CSS and js via the named tools.

 

Any expert here to give hints`?

 

thanks alot

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...