What is Gzip compression and what is it for

The time it takes to transfer an HTTP request and its response over the network can be significantly reduced by the decisions made by the engineers on the front-end

It is true that the bandwidth, Internet provider, proximity to exchange points, etc. user, they are outside the control of the development team. But there are other variables that affect response times. Compression reduces response times by reducing the size of HTTP requests.

As of HTTP / 1.1, web browsers allow support for compression with the Accept-Encoding header in the HTTP request.

Accept-Encoding: gzip, deflate

If the web server displays this header in the request, it can compress the response using one of the methods listed by the client. The web server notifies the client through the Content-Encoding header in the response.

Content-Encoding: gzip

Gzip is the most popular and effective compression method right now. It was developed by the GNU project and standardized by RFC 1952. The other compression format you can use is Deflate, but it is less effective and less popular.

Compressing with Gzip generally reduces the size of the response by up to 70%. About 90% of Internet traffic today travels through browsers that specify support for Gzip. If you use Apache, the Gzip configuration module depends on the version: Apache 1.3 uses mod_gzip while Apache 2.x uses mod_deflate.

There are known issues with browsers and proxies that can cause an imbalance in what the browser expects and what it receives in relation to compressed content. Fortunately, these cases are decreasing as the use of older browsers is also decreasing. Apache modules help by adding the appropriate headers automatically.

Servers choose what to compress, based on the type of file, but are often very limited in what they decide to compress. Many websites compress their HTML documents. Compressing your scripts and stylesheets is also recommended, but many websites miss out on this quality. In fact, it is useful to compress any text including XML and JSON responses. Images and PDF documents should not be treated with Gzip as they are already compressed. Trying to do so not only wastes CPU resources, but increases the size of the file.

Treating with Gzip as much file type as possible is an excellent way to reduce the weight of the page and speed up the load for the user.

Date update on 2020-11-13. Date published on 2020-11-13. Category: Computer class Author: Oscar olg Fuente: tecnologia