Enable Compression - PageSpeed ​​Insights

When and why you should turn on compaction for your website.

What to do when the PageSpeed ​​review suggests that you turn on your site's compression, see the steps required to enable this feature in WordPress or Magento.

How and when to Enable Compression for your website

Example message in PageSpeed

Compacting features with gzip or deflate can reduce the number of bytes sent over the network.
Enable compression for the following features to decrease the transfer size in 328,4 KiB (73% reduction).

Who should do this?

You should enable compression when the PageSpeed ​​Insights detects that compressible passive resources have not been compressed.

All modern browsers automatically support gzip compression for all HTTP requests.

Enabling gzip compression can reduce the response size by up to 90%, which can significantly reduce the amount of time to download the feature, reduce data usage for the client, and improve the rendering time of your pages.

Recommendations to enable compression

Enable and test gzip compression support on your web server.

The HTML5 Boilerplate project contains sample configuration files for all most popular servers with detailed comments for each configuration and configuration flag: find your favorite server in the list, browse to the gzip section, and confirm that your server is configured with the recommended settings.

See your web server's documentation for how to enable compression.

Apache

Typically sites / virtual stores like Magento, WordPress, PHP platforms are running on an Apache server.

Enabling Gzip Compression via .htaccess

Configuring compression directly on the server has several benefits.

On the one hand, plugins come with a lot of indirect data, which increases the risk of conflicts with other plugins and errors.

Also, if compression is all you're looking for, installing a large plugin with dozens of other functions does not make sense.

As mentioned earlier, the server file responsible for enabling these features is called .htaccess (yes, including the dot).

It is used to implement special instructions for the server.

For example, when you set up enough permalinks in WordPress, CMS adds rewriting rules to .htaccess for this to happen.

Other things this file can do are redirects, protecting files and folders from access and more, including Gzip compression.

Here's how to do the latter.

Find and edit .Htaccess

To make changes to the file Htaccess, we must first find it. This is not always easy because it is hidden by default.

The easiest way to access .htacces is via FTP, but you can also use cPanel or any other administration interface.

In our case, let's start by opening our FTP client and connecting it to the server.

.htaccess is usually found in the root directory of your site. However, as I mentioned, it is often invisible.

In FileZilla, you can change this in Server> Force showing hidden files.

forcing hidden files to show

However, your access mode may have the option elsewhere.

After that, you can edit the file just like any other file. In Filezilla this means right-click and then View / Edit.

editing file

Add the required code

Add the following code at the end of the .htaccess file and save it to your server.

<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 AddOutputFilterByType AddOutputFilterByType AddOutputFilterByType AddOutputFilterByType AddOutputFilterByType DEFLATE application / x-font-ttf / xml AddOutputFilterByType DEFLATE font / OpenType font AddOutputFilterByType DEFLATE / 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 BrowserMatch ^ Mozilla / 4 \ .0 [678] no-gzip BrowserMatch \ bMSIE! no-gzip! gzip-only-text / html Header append Vary User-Agent </ IfModule>

Now you can check if Gzip compression is working on your site.

Run the PageSpeed ​​test again and make sure your website's note has improved.

References

http://httpd.apache.org/docs/current/mod/mod_deflate.html

Rate This Article!

Click on the stars to give a note of 1 to 5.

1 star2 stars3 stars4 stars5 stars (No Ratings Yet)
Loading ...

Write a review "Enable Compression - PageSpeed ​​Insights"

  1. My husband and I stumbled across a different website and thought I should check things out. I like what I see then just follow you.Thank you for reviewing your webpage over and over again.

Doubts? Make a comment below or send us a message by clicking here.

Your email address will not be published. Required fields are marked with *