Magento 2 Slow? Speed Up Magento 2 (2021)

Magento 2 Slow? Speed Up Magento 2

 

We are learning the basic Magento 2 performance setup in our last blog. also, We have checked how we can test our website using google page speed and GT Metrix. If you are not aware of it, then click here πŸ‘‰ Magento 2 Performance Optimization

Magento 2 system Requirement

 It’s very important to choose the best server. If the particular server you picked is not functioning smoothly, you won't have good website speed. Before starting performance optimization in Magento 2, We suggest you use the best server.

Always use the dedicated server or VPS, do not pick a shared hosting option.

Check the Magento 2 system requirement before you purchase the server.

  • Memory requirement: Memory should be 2 GB RAM or higher.
  • Database: Use always the latest MySQL version.
  • PHP: Use the always updated PHP version.
  • Magento  Version: Use the always latest Magento version.
  • SSL: A valid security certificate is required for HTTPS. Self-signed SSL certificates are not supported. 
  • Mail server: Mail Transfer Agent (MTA) or an SMTP server
Note : If you want to check more about system requirement guidelines, then go to the magento official website. Click Here πŸ‘‰Magento system requirements

CDN (Content Delivery Network)

It's used to reduce a load of your server by serving some of the website’s content. So, It brings high performance by delivering your content quickly.
AWS (Amazon CloudFront) Server :
Amazon CloudFront is a highly secure Content Delivery Network (CDN) that provides both levers (network and application) protection. 
Magento can utilize the following technologies :
  1. Varnish Cache
  2. Redis Page cache
Magento Full-page Cache
When a customer is accessing your website, a request is made to the server.  At a time returning the corresponding HTML to be displayed to the user. Full-page cache stores that HTML response, so that the next request will directly return it, skipping all the back-end processing and database queries. So, using the full-page cache makes the website much faster.

We can enable the full page cache using the below command:
php bin/magento cache:enable full_page

How to use Varnish for Full-page Cache
After, Enabled the full page cache, Use Varnish to handle it, not files. Magento strongly recommends using Varnish OR  Redis in production mode.

The varnish is designed to accelerate HTTP traffic. How to set up the varnish cache, Magento provides it on the official website. click here πŸ‘‰Install Varnish

Let's configure the Varnish cache.


  1. Log in to the Magento Admin Panel.

  2. Go to the Stores > Configuration > Advanced > System > Full Page Cache

  3. Now, Open the “Caching Application” and select the “Varnish Cache (Recommended)”

  4. Enter the TTL for public content.

  5. You can check the Varnish Configuration as per the below screenshot and enter the given information about the Varnish configuration.

Magento 2 Slow? Speed Up Magento 2 (2021)


Some tips for improving in coding Full-page Cache Works.

1)Don’t use the attribute cacheable="false" in the layout XML block.

2)Always use production mode in live websites.

3) test whether or not your page is cached manually. You can put the store on developer mode and run the cache clean command. Inspect element and check the Network tab. Refresh the page.

GZIP Compression

Gzip is a method of compressing files for faster network transfers. You can check in GTmetrix regarding the GZip.

How Can we enable it?

For Apache servers
Copy and paste the following code into your .htaccess file:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Use Elasticsearch on Search and Catalog Pages
 Using Elasticsearch you can increase your website speed. First, you need to set up your Elasticsearch server and connect your Magento website. Using ElasticSearch, Searching becomes much faster.

Visit the Magento 2 official website for how you can πŸ‘‰ configure Magento with Elasticsearch

Let's Configure,

1. Open the Admin Panel.
2. Go to the Stores > Settings > Configuration > Catalog > Catalog > Catalog Search.
3. From the Search Engine list, click Elasticsearch or Elasticsearch 6.0+ 
Magento 2 Slow? Speed Up Magento 2 (2021)
Remove the Unnecessary Ajax Calls
Ajax call takes more time to load the page. So, use only necessary Ajax Calls and remove the unuseful ajax call.
Go to the Network tab and there you can filter the request by XHR. you can see all the Ajax requests of the page and check them to see which of them are useful on that particular page.
Set the Indexers to “Update on Schedule”
Magento 2 indexers provide the  below two modes
1)Update on Save 
2)Update on Schedule

If set to “Update on Save” every time you save a product, category, or Attribute, the specific index starts running. that's why your server becomes down.

So, set the "Update on Schedule" indexer, Indexer are executed by the cron job at a specific time that you set. 
Ask Question #trycoder
Facebook PageπŸ‘‰ https://bit.ly/3o688OF
TwitterπŸ‘‰ https://bit.ly/2LNwmAb
Watch more videos here
Click to SUBSCRIBE to more Videos!

Please Like, Comment, Share and Subscribe THANK YOU!

0 Comments