My client's Magento site page load speed is very slow. What can I do to decrease page load time?

The site url is desibazaar.pk.

up vote 34 down vote accepted

First determine if it's front end rendering or the actual script execution that is slow. Check with the developer console in your browser for the Time To First Byte. This is how long the script take to process on the server

enter image description here

In the screenshot you can see it's quite low (200ms) so in this case the problem wouldn't be on the server but on front end. Now if it's over, let's say, a second you might want to optimize.

Before you slap on some boosters and extra caching which isn't a fix just a patch or band aid to hide the real issue try to figure out what exactly is slow. You can use several tools also for that.

Slow queries

Magento can be quite heavy on the database so turning on the Slow Query Log might be a good place to start. Check out this post on how to turn it on. The log will show you any query that takes longer than X seconds.

Profilers

Profilers help you gain insight into whats going on in your code. For Magento I would recommend starting with Aoe_Profiler. Just install it and turn it on. On the front end it'll give you an output like this:

enter image description here

Expand the results and check for large red blocks. Those are the actual times it took a certain part of the code to process. Look out for any 3rd party modules that are taking up a lot of time or memory.

Another great tool is Black fire. Since Aoe_Profiler is a module in Magento it doesn't show the underlying php processes and can crash on large installations with a lot of modules. Black fire runs on the server. With a hackathon we set up a Vagrant box with black fire you can use. Just put your project on there and fire it up. Check the Black fire site for more info how to use it.

Last one is probably my favorite: New Relic.

Unfortunately it's a paid service although they provide a free trial for pro accounts. After installing it on your server and connecting the profile wait a couple of hours for data to come in. Make sure there is some traffic on the shop tho.

enter image description here

New Relic also has a blog post on how to debug Magento which I can recommend. Also check out the ProxiBlue New Relic module for extra Magento data in New Relic.

Basically this will show you all of the above described features like slow queries, the processes in PHP etc and display it in easy graphs and tables. This should give you great insight in what is the issue in your installation.

And from here Now that you know what is causing the low performance you can move on to solving it. Check forums like this one or Google for the part or module of Magento that is slow. A lot of issues are well known and others have solved it before. Or, if you can't find a solution post your question here and include your findings in the question

  • Excellent.. Thanks for the insight about "BlackFire" – Rajeev K Tomy Sep 16 '15 at 5:14
  • Wow, thank you for this! – Ner Nov 18 '17 at 12:36

Site speed optimization in Magento is very vast topic. This is one link which can help you,

http://www.gxjansen.com/blog/101-ways-to-speed-up-your-magento-e-commerce-website/

Taking a gist of it,

You need to concentrate on two aspects, 1. Frontend optimization 2. Backend optimization

Frontend optimization

  1. You can install Fooman Speedster - http://www.magentocommerce.com/magento-connect/speedster-by-fooman.html and enable css , js merge

  2. Enable Magento block caching in admin.

  3. Enable Gzip compression

Backend Optimization

  1. You can configure Varnish for full page caching

  2. Enable complication in backend.

  3. Enable flat structure for catalog (category and products)

Here's a couple little tricks I found to help speed up your site you might want to try:

Defer Image loading by adding this to the /template/page/html/head.phtml

<script>
function init() {
var imgDefer = document.getElementsByTagName('img');
for (var i=0; i<imgDefer.length; i++) {
if(imgDefer[i].getAttribute('data-src')) {
imgDefer[i].setAttribute('src',imgDefer[i].getAttribute('data-src'));
} } }
window.onload = init;
</script>

Then in /template/catalog/product/list.phtml change your image links like this:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AQQATUqB0EhKgAAAAxJREFUCNdj+P//PwAF/gL+3MxZ5wAAAABJRU5ErkJggg==" data-src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>

Another one is to "Pre Gzip" all your javascripts and CSS files then add this to your .htaccess.

    <ifModule mod_headers.c>
    ##### serve pre gziped files #####
    # Rules to correctly serve gzip compressed CSS and JS files.
    # Requires both mod_rewrite and mod_headers to be enabled.
    # Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.css $1\.css\.gz [L,QSA]

    # Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.js $1\.js\.gz [L,QSA]

    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
</IfModule>

Magento is a great e-commerce framework. It has tons of features and you can really build a scalable e-commerce platform. I used Magento in my latest project and faced this speed issue. After doing some research and modification I really sped up my website.

Server Optimization

  • Use Nginx as web server
  • Move MySQL to different server with master-slave replica. If you are on AWS use RDS for MySQL.
  • Optimize Nginx & Php-fpm
  • enable gzip compression
  • Enable Browser cache

Magento Settings

  • Disable all unnecessary extensions
  • Merge CSS and JavaScript files
  • Disable Log
  • Clean up Magento log tables
  • Enable External full page cache

Install Redis Cache, APC Opcode & Full Page Cache extension - Install PHP Accelerators - Install Redis cache for backend & session caching - Install Lesti FPC

Image Optimization & YSlow - on an average 56 percent of a website’s page weight is made up of images. Optimizing your product images can dramatically increase the speed of your pages as this decreases their download times. - Scan your website through gtmetrix or Pingdom and follow their optimization suggestions.

Use CDN

You can read details about this on my website: http://www.ranjeetvimal.com/tips-to-speed-up-magento-1-9-performance/

if you are on a shared hosting environment it is very difficult to achieve good speed as one do not have full control over server and the resource is used by several other websites, but if you are on dedicated server and have full admin access try varnish cache.

other things you can do -

1.Combine JS and CSS files

Magento admin -> System Configuration -> Developer -> Under “Javascript Settings”, change “Merge Javascript Files” to YES.
Magento admin -> System Configuration -> Developer -> Under “CSS Settings”, change “Merge CSS Files” to YES

2.Enable Output Compression, Expires Headers and Disable ETags in .htaccess file see this https://stackoverflow.com/a/14745165/3114253

  1. Use CDN if Possible

  2. Use Magento’s Compilation feature. It’s reported to give you a 25%-50% performance boost: System > Config. > Tools > Compilation.

  3. Show lesser no. of Product in Product listing Page.

  4. Enable flat catalog.

From the Magento administrator interface, go to System > Configuration > Catalog. Under Frontend, change Use Flat Catalog Category to YES. If desired, under Frontend, change Use Flat Catalog Product to YES. Clear the cache.

To increase magento website speed you might want to first scan it with www.gtmetrix.com or Google Page Speed Insights:

Google Page Speed Score

then you can decide what could be done. In most cases it comes down to:

  • optimize time to first byte (TTFB) to lower server response time
  • defer parsing of Javascript
  • optimize images
  • use CSS sprites
  • set image dimenstions
  • minify CSS/JS/HTML
  • merge JS/CSS to lower number of HTTP requests

If you try to speed up your frontend:

  • use a CDN for images (!) and reduce the image size
  • concatenate CSS and JS
  • load JS before the closing body tag
  • use asynchronous js loading whenever possible
  • use image sprites or an icon-font instead of thousands of png files
  • reduce unused CSS
  • generate a critical path for your css

Backend:

  • use an additional cache like varnish (TTFB < 15ms) or LestiFpc
  • profile your page-loading and complex MySQL Queries and fix them
  • activate gzip, etags, browser-cache etc. via .htaccess
  • use MySQL on a single Server
  • Please do not link to paid services with your invitation URL for your own personal gain. – 7ochem Dec 1 '16 at 12:13

protected by Community Jan 30 at 16:54

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.