Enable Gzip Compression For Your Magento 2 Store

ENABLE GZIP COMPRESSION FOR YOUR MAGENTO 2 STORE

Gzip compression is one of the few techniques that can significantly improve the speed of your website. Faster speeds mean much more user-friendly interface which in turn will draw more customers to your store. Today we will understand how to enable Gzip compression for your Magento 2 store. You may find it quite complicated so follow the steps in the article below carefully. 

What is Gzip Compression?

Gzip compression is a standard method of compressing larger files on your website. It will enable your webpages to load much faster providing for a smooth experience. Whenever a customer visits your store they request files from the server and if these files are large in size then it will take longer for them to be delivered to the user causing a delay in the loading. In simple terms, the larger the file, the more time it will take to load the webpage for your users. Moreover, Gzip compression provides you with an effective method to compress the files before they are sent to the browser hence reducing the response time. 

Furthermore, from our own experiences as well as through extensive research, we have determined that Gzip compression is extremely efficient and necessary for Magento 2 stores. This is not an option you want to ignore if you want your store to be fast. Good loading times provide for better user experience for your customers and makes it highly likely for them to visit the store again. Now, let us learn step by step to enable the Gzip compression for your Magento 2 store.   

Steps to Enable Gzip Compression For Your Magento 2 Store

Follow the steps below to successfully enable Gzip compression on your Magento 2 store:-

  • Assure the mod_deflate is on in apache. You can do that by creating an info.php file and calling phpinfo(); You will get the specs of PHP/APACHE on the browser. Remove it when you have completed the process.
  • Navigate to your htaccess file and add the code given below:- 
 
  • That’s all you are done.
<IfModule mod_php5.c>
## enable resulting html compression
php_flag zlib.output_compression on
</IfModule>
<IfModule mod_php7.c> ## enable resulting html compression php_flag zlib.output_compression on
</IfModule>
<IfModule mod_deflate.c>
## Force compression for mangled `Accept-Encoding` request headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)s*,?s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
## Compress all output labelled with one of the following media types.
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE "application/atom+xml" "application/javascript" "application/json" "application/ld+json" "application/manifest+json" "application/rdf+xml" "application/rss+xml" "application/schema+json" "application/vnd.geo+json" "application/vnd.ms-fontobject" "application/x-font-ttf" "application/x-javascript" "application/x-web-app-manifest+json" "application/xhtml+xml" "application/xml" "font/eot" "font/opentype" "image/bmp" "image/svg+xml" "image/vnd.microsoft.icon" "image/x-icon" "text/cache-manifest" "text/css" "text/html" "text/javascript" "text/plain" "text/vcard" "text/vnd.rim.location.xloc" "text/vtt" "text/x-component" "text/x-cross-domain-policy" "text/xml"
</IfModule>
## Map the following filename extensions to the specified
## encoding type in order to make Apache serve the file types
## with the appropriate `Content-Encoding` response header
## (do note that this will NOT make Apache compress them!).
<IfModule mod_mime.c>
AddEncoding gzip svgz
</IfModule>
</IfModule>

If you do not want to get into the technicalities then you can contact us HERE. We have a team of experts standing by to help you get through the task.

For more information on speeding up your Magento 2 store READ.                                                 

Discover more from WHO WILL CARE eCommerce

Subscribe now to keep reading and get access to the full archive.

Continue reading