Today's Question:  What does your personal desk look like?        GIVE A SHOUT

Make Magento 2 Faster: Five Quick tips

  JamesWarner        2016-07-14 00:17:45       8,634        2    

In this post, you will learn from Magento development company experts about speeding up the Magento 2. We hope these tips will help you in making Magento 2 faster than before.

Magento 2 is a powerful platform. Once installed and with no customization it is a fully functional store. They even give you a well-designed, responsive storefront. However as you add products and your own content things will incrementally begin to slow down. To combat that there are some things you can do to increase speed thus improving the customer experience.

As part of a prelaunch checklist add these five things to give your store a boost: Minify scripts, Use a CDN, Configure the PHP memory on the server, enable the expires header, and use Apaches mod_deflate feature.

Minify Scripts

To minify a script or css file is as simple as removing all the useless space in the file. Thats all of your tabs and spaces. All of that space takes up space. Once you remove it it the server will have a smaller file to move to your customer's computer or device.

To do this: 

  1. Go to Stores > Configuration > Advanced > Developer
  2. Open the Javascript area and select Yes for Merge and Minify 
  3. Open the CSS area and select Yes for Merge and Minify
  4. Save Config

For this to be successful you first need to make sure your js and css selectors naming conventions are unique. Care should be taken to follow BEM standards. Otherwise when everything is merged together you will get conflicts.

Use a CDN

A content delivery network is an optimized source for content. Instead of providing all content to your visitor s you can take advantage of services that Google offers. An example would be your fonts and javascript libraries. Google already has fast servers that are feeding other servers around the globe. You can call out to Google to feed your fonts into your site. You can serve jQuery and Angular this way too. Its a team effort and its a great free service.  Check out all Google can serve to you: 

https://developers.google.com/speed/libraries/

Configure PHP Memory

Open up your htaccess file in your root directory and type in the following:

###########################################3
##adjust memory limit

php_value memory_limit 256M
php_value max_execution_time 18000


In the above code you can alter the memory limit. For speed bump it up to 1024M.Be careful to limit what you do to execution time. 18000 is a safe limit. Anything higher could hinder security. If your site is ever hacked then that also means harmful php scripts can run longer. Enable the expires header This is great for speeding up your Magento 2 store, especially for your repeat customers. This feature will allow static files to be cached on the customer’s computer. So the things that don’t change much like product images and banner sliders. This will give the appearance of an improved load time. To do this simply open your htaccess file back up and enter the following:


######################################################
## Add default Expires Header
## http://developer.yahoo.com/performance /rules.html#expires
ExpiresActive On
ExpiresDefault “access plus 1 year”

Use Apache Mod Deflate

This feature allows content from your server to be compressed before it goes out to a client’s computer.  This one is also in htaccess:

 

############################################ 

## enable apache served files compression 

## http://developer.yahoo.com/performance/rules.html#gzip

## Insert filter on all content SetOutputFilter DEFLATE 

## Insert filter on selected content types only

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/ css text/javascript 

## Netscape 4.x has some problems... 

BrowserMatch ^Mozilla/4 gzip-only-text/html 

## Netscape 4.06-4.08 have some more problems 

BrowserMatch ^Mozilla/4\.0[678] no-gzip 

## MSIE masquerades as Netscape, but it is fine 

BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 

## Don't compress images 

SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary 

## Make sure proxies don't deliver the wrong content 

Header append Vary User-Agent env=!dont-vary 

 

All of these quick tips should be a part of your pre-launch checklist. You need to start of right and provide a fast solution to your customers.

Magento development company experts have shared all five tips to boost Magento 2 speed. If you still want to know more about the subject, feel free to ask the experts.

MAGENTO  MAGENTO TUTORIAL  MAGENTO DEVELOPMENT 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  2 COMMENTS


AlexMorco [Reply]@ 2017-09-20 07:32:01

Thanks for sharing this post, I am not technical person, But, I know cache matters a lot for speed optimization, I have been using Magento for a long time and I was disturb due to my store loading issue, I tried lot of things to fix the issue, I just move my hosting to cloudways managed Magento hosting and their support agent run Magento full page cache extension which is free of cost, My store speed is now well and loading in 2 seconds.

Stan [Reply]@ 2018-03-22 08:19:12

Stop suggesting things that don't work. Merge of JS and CSS files does not work correctly in Magento 2. It does not merge 90% of files, which are loaded by require.js. You can learn more in this article - https://potatocommerce.com/why-merge-of-javascript-and-requirejs-bad