Delivering better user-experience is the key to selling more online. People will abandon your cart if the site takes more than 2 seconds to load. That’s why it becomes crucial to speed up Magento stores. In this blog, you will learn about Magento performance optimization tips to boost your sales.
Magento Performance Optimization Tips
1. Setup & Configuration
- Choose Magento Optimized Hosting
- Magento Server Configuration
- Dedicated Resources Optimization
- Upgrade to Latest version of PHP
- Use HTTP/2
2. Magento Optimization
- Optimize TTFB
- Magento Image Optimization
- Minimize Latency
- Optimize Fully Loaded Time
- Optimize Start Render Time
3. Magento Caching
- Go for CDN
- Browser Caching
- Full Page Caching
- Opcode Cache
4. Auditing
- Auditing Tools
- Audit Magento Code
Magento Setup & Configuration
1.1. Choose Magento Specific Hosting
If you have a Magento site, don’t fall $5 tag. Your website indicates your business, go for a faster Magento hosting that takes care of the speed, security, resource utilization, and uptime 24*7.
1.2. Magento Server Configuration
Magento performance optimization means choosing the right hosting for your website and optimized Magento server. If you’re with the right host, they’ll take care of the provisioning and hardware requirements.
1.3. Optimizing Dedicated Resources for Magento
If you’re planning to run your Magento on a dedicated server or a VPS, optimize server software and a database. There are many options for server setup depending on the expertise. For Magento performance optimization, you can go for Varnish, Nginx, Redis, PHP7.
Misconfiguration of servers can lead to slow Magento sites. Few of the mistakes are:
1. Slow disk I/O: Your store could be slow because of HDD. Therefore, we use SSD (Solid State Disk) to speed up Magento.
2. Disabled MySQL query cache: MySQL servers have their query cache disabled by default. For Magento performance optimization, enable the caching.
3. Resource bottleneck: Whenever there aren’t enough resources (for example, RAM), it puts data on disk making things slow.
1.4. Upgrade to latest PHP7
If your website is still running on an older version of PHP, update immediately to see improved performance.
1.5. Move to HTTPS/2
HTTPS/2 is the newer version of HTTPS which has a lot of performance improvements. It allows the browser to use fewer resources and load a website faster.
All the major web servers like IIS, Nginx, Apache etc support HTTPS/2.
Magento Optimizations
2.1. Optimize TTFB
Time to First Byte or server response time is the time spent waiting for the initial response. It captures the latency of the server response going and coming back to the server. The higher the TTFB, the slower is your website. To reduce server response time Magento codebase needs to be scanned.
Google recently indicated the use of the Chrome User Experience Report and lab data from Lighthouse to improve speed. The First Contentful Paint (FCP) and the First Input Delay (FID) should between 0-1000ms and 0-50ms.
2.2. Optimize Fully Loaded Time
After optimizing TTFB
1. Minimize the number of 3rd party JS scripts
2. Don’t rely too much on jquery.ready.
2.3. Optimize SRT
Start Render Time (SRT) is the moment when a user sees the content after requesting the webpage. It could be a logo, background color, or a search box.
SRT consists of:
- Time it takes to download HTML
- TTFB
- Initial layout calculation
- Downloading resources (JS/CSS external files) and section parsing
2.4. Magento Image Optimization
There are 3 ways to reduce image size:
1. PageSpeed Server Module: Google offers PageSpeed Modules which helps in optimizing the website automatically. You just need to install it in your web servers.
2. Command-line Tools: To use this method, you need to be familiar with Linux and Bash. You can use:
To minimise images in bulk, run the following script:
#!/bin/bashfind ./media -iname '*.gif' -exec sh -c ‘gifsicle -b -O3 -o "{}.out"
"{}"; mv "{}.out" "{}"' ;find ./media -iname '*.png' -exec optipng -o5 -keep -preserve
'{}' ;find ./media -type f -iname '*jpg' -exec sh -c 'jpegtran -outfile "{}.out" -optimize
"{}"; mv "{}.out" "{}"' ;
3. WebP: WebP is a modern image format that helps in compressing images without compromising the quality. It provides superior lossy and lossless compression for web images helping in making the web faster.
2.5. Minimize Latency
You should host your website as close to your target audiences as possible. If your main audience is in India, hosting your website in the US will slower the site speed. That’s the reason, we are built on the top of AWS which has availability zones across the globe.
Magento Caching
3.1. Setup a CDN
Content Delivery Network (CDN) is a geographically distributed network of proxy servers and their data centers. A CDN stores a cached version of the content in multiple locations.
CDN is a must for anyone aiming to speed up Magento website. All our Magento plans include CDN (CloudFlare CDN, Sucuri CDN) for free.
If your hosting provider doesn’t provide CDN. You can setup it yourself. CDN is supported by default. You don’t need an extension to add a CDN to your Magento store. To enable:
System > Configuration > Web > Set secure/unsecure URLs for media, skin, js resources.
3.2. Leverage Browser Caching
You can lower the SRT or Start Render Time by leveraging browser caching to load your website faster.
Browser caching means you can specify how long web browser should keep CSS, JS, and images locally. Thereby, the user’s browser will download less data while navigating through your web pages, thus, improve Magento speed.
Enable browser caching by adding the following to your .htacess file:
EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
## EXPIRES CACHING ##
You can modify the .htaccess file via File Manager or FTP in cPanel.
Note: You need to enable ‘enable mod_expires’. Write the following command and restart Apache server:
sudo a2enmod expires
Enabling module expires.
Run '/etc/init.d/apache2 restart' to activate new configuration!
For Nginx, you need to use the following command:
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
location ~* .(pdf)$ {
expires 30d;
}
}
3.3. Full Page Caching
FPC caches the complete page making Time to First Byte under 500ms.
For Magento 1
- Go to the Admin menu
- Select System
- Go to Configuration
- Go to “Advanced” on the left of the panel
- Select System
- Click to expand the “External Full Page Cache” settings
- Set Enable External Cache to “Yes”
- Set External Cache-Control to “Zend Full Page Cache”
For Magento 2
- Go to “Stores” on the Admin sidebar
- Choose “Configuration” under settings
- Choose “System” under Advanced
- Expand the “Full Page Cache” section and set “Caching Application” to one of the following:
- Varnish Caching
- Built-in Application
- Enter “TTL for public content” for setting the time-out for the page cache. The default value is 86400.
- Complete the “Varnish Configuration” by entering the following details:
- Go to “Access list field” > enter the IP address that can purge the Varnish configuration to generate a config file. The default value is “localhost”.
- In the Backend host field > Enter the IP address of the backend host that generates config files. The default value is “localhost.”
- Identify the backend port that is required to generate config files in the Backend port field.
Default value is “8080.” - Export the config as a “varnish.
vcl ” file by tapping the button for the version of Varnish you need.- Export VCL for Varnish 3
- Export VCL for Varnish 4
3.4. Opcode Caching
You can install a PHP opcode cache like eAccelerator or APC. At Webscoot, we offer in-built opcode caching for optimized Magento performance.
Magento Auditing
4.1. Magento Audit Tools
Here are some of the auditing tools:
4.2. Audit Magento Code
If your Magento is slow, start by profiling the code and identify parts that take time to load. PHP code and template files could be a reason for a slower server response time. Although Magento comes with a built-in profiler, you can also use tools and extensions like:
- New Relic
- BlackFire
- Aoe
You can read about auditing fundamentals to know how to speed up Magento. Or simply ask your host to perform an audit.
Conclusion
Improving Magento performance will boost your revenue. Follow Magento community to get answers if you get stuck somewhere. At Webscoot, we offer Magento optimized hosting, server-level caching, and CDN that will speed up Magento stores instantly.
Sakshi takes care of everything related to Marketing at Webscoot.io. She has knowledge about Magento, WordPress, and Dogs.
magento is a beast and takes very large server resources
and has slow performance than others
Hi Gopal. Magento does require more resources than WooCommerce or OpenCart but comes with a lot of extensibility and customisations. And if configured properly by a Managed Magento Hosting partner, it can be very very smooth and much better than an out-of-the-box plain linux server.
right magento has slow performance
Nice Guide for Magento Performance Optimization!
Regarding Image Optimization you even mention WebP Images as one option, but no info on how this can be implemented in Magento.
Nowadays, eCommerce buyers are impatient. The loading speed of a website is a crucial component that search engines evaluate when ranking each web page. As a result, every Magento owner should track the store’s performance. This is the basis for Magento performance improvement. Installing performance-enhancing extensions will increase the performance of your Magento shop. These will improve user experience and, as a result, sales.