The purpose of HTTP compression is to reduce the size of the files sent by a web server by eliminating redundant information in those files. The smaller the size of the files, the more quickly they can be served over the World Wide Web.
What HTTP compression aims to do is reduce the size of these files on the server by putting these files through compression algorithms before sending over the compressed versions to a client such as a web browser. When the browser receives the compressed file, it will decompress it quickly using the same compression algorithm before displaying the web page content inside the browser window.
HTTP compression thus removes the redundant information in such files before letting the files leave the web server. The compressed file is smaller and thus reaches the web browser much more quickly, using less bandwidth too. When the web browser receives the compressed file that has all the redundant information removed, it knows how to decompress the file back to its original, uncompressed state on the web server by replacing the redundant information that was stripped out.
There are different HTTP compression algorithms such as Gzip, DEFLATE, and Brotli, the newest kid on the block. Prior to Brotli, Gzip was the more popular option, but Brotli is increasingly preferred because it offers a 20-30% reduction in compression size compared to Gzip with similar decompression speed.
File compression using HTTP compression algorithms has to be performed by the web server. Popular HTTP server software such as Apache and Nginx support most, if not all of the compression algorithms out of the box. When requesting content from a web server, your browser can inform the web server through the HTTP request header that it accepts compressed information by including another line like this:
Accept-Encoding: gzip, deflate, br
The request header information above tells the web server that the browser can accept content compressed with either Gzip, DEFLATE, or Brotli.
If HTTP compression is enabled on the web server, the web server will return a compressed version of the requested files. In the HTTP response header back to the browser, the web server will inform the browser the type of encoding that has been used using a line like this:
The response header above tells the browser that the web server has sent back content compressed with the Brotli algorithm. The browser then knows to decompress the content back to its original state using the Brotli algorithm.
The entire compression and decompression processes happen very quickly in the background without you noticing them at all.
HTTP is a protocol used to connect to web servers by web browsers to request content to view. This is also used to transfer larger files, and is often used for software updates.
Any (specific) format used to transfer or save information. This is used in video, file types and more.
Compression involves running an algorithm to make a file/image/etc. smaller. There are two modes of compression: lossy and lossless.
A GIF refers to images encoded in the Graphic Interchange Format (GIF).
A PNG refers to images encoded in the Portable NetWork Graphics format (GIF).
A JPEG refers to an image encoded in the Joint Photographic Experts Group (JPEG) format.
CSS refers to a Cascading Style Sheet (i.e. styling used to "decorate" a page).