Content deleted Content added
a_"pa". Tags: Reverted Visual edit |
→Content-Encoding tokens: Lzip compression also supported by Links |
||
(23 intermediate revisions by 16 users not shown) | |||
Line 1:
{{HTTP}}
'''HTTP compression''' is a capability that can be built into [[web server]]s and [[web client]]s to improve transfer speed and bandwidth utilization.<ref>{{cite web|url=http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d52ff289-94d3-4085-bc4e-24eb4f312e0e.mspx?mfr=true|title=Using HTTP Compression (IIS 6.0)|access-date=9 February 2010|publisher=Microsoft Corporation}}</ref>
HTTP data is [[Data compression|compressed]] before it is sent from the server: compliant browsers will announce what methods are supported to the server before downloading the correct format; browsers that do not support compliant compression method will download uncompressed data. The most common compression schemes include [[
There are two different ways compression can be done in HTTP. At a lower level, a Transfer-Encoding header field may indicate the payload of an HTTP message is compressed. At a higher level, a Content-Encoding header field may indicate that a resource being transferred, [[Web cache|cached]], or otherwise referenced is compressed. Compression using Content-Encoding is more widely supported than Transfer-Encoding, and some browsers do not advertise support for Transfer-Encoding compression to avoid triggering bugs in servers.<ref>[https://code.google.com/p/chromium/issues/detail?id=94730 'RFC2616 "Transfer-Encoding:
==Compression scheme negotiation==
The negotiation is done in two steps, described in RFC 2616 and RFC 9110:
1. The [[web client]] advertises which compression schemes it supports by including a list of tokens in the [[HTTP request]]. For ''Content-Encoding'', the list is in a field called ''Accept-Encoding''; for ''Transfer-Encoding'', the field is called ''TE''.
Line 14:
GET /encrypted-area HTTP/1.1
Host: www.example.com
Accept-Encoding:
</syntaxhighlight>
2. If the server supports one or more compression schemes, the outgoing data may be compressed by one or more methods supported by both parties. If this is the case, the server will add a ''Content-Encoding'' or ''Transfer-Encoding'' field in the HTTP response with the used schemes, separated by commas.
<syntaxhighlight lang="
HTTP/1.1 200 OK
▲a"a:"te: mon, 26 June 2016 22:38:34 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Line 29 ⟶ 27:
Connection: close
Content-Type: text/html; charset=UTF-8
Content-
</syntaxhighlight>
Line 40 ⟶ 35:
The official list of tokens available to servers and client is maintained by IANA,<ref>{{cite web|url=https://www.iana.org/assignments/http-parameters/http-parameters.xhtml#content-coding|title=Hypertext Transfer Protocol Parameters - HTTP Content Coding Registry|publisher=IANA|access-date=18 April 2014}}</ref> and it includes:
*br – [[Brotli]], a compression algorithm specifically designed for HTTP content encoding, defined in
*[[compress]] – UNIX "compress" program method (historic; deprecated in most applications and replaced by gzip or deflate)
*deflate – compression based on the [[DEFLATE|deflate]] algorithm (described in
*exi – W3C [[Efficient XML Interchange]]
*[[gzip]] – GNU zip format (described in
*[[Identity function|identity]] – No transformation is used. This is the default value for content coding.
*[[Pack200|pack200-gzip]] – Network Transfer Format for Java Archives<ref>{{cite web|url=https://jcp.org/en/jsr/detail?id=200|title=JSR 200: Network Transfer Format for Java Archives|publisher=The Java Community Process Program}}</ref>
*[[zstd]] – Zstandard compression, defined in
In addition to these, a number of unofficial or non-standardized tokens are used in the wild by either servers or clients:
*[[bzip2]] – compression based on the free bzip2 format, supported by [[lighttpd]]<ref>{{cite web|url=http://redmine.lighttpd.net/projects/1/wiki/Docs_ModCompress|title=ModCompress - Lighttpd|publisher=lighty labs|access-date=18 April 2014}}</ref>
*[[lzip]] – compression based on the free lzip format, supported by [[wget]]<ref>{{cite web|url=https://lists.gnu.org/archive/html/bug-wget/2021-09/msg00020.html|title=GNU Wget2 2.0.0 released|access-date=14 May 2025}}</ref> and [[Links_(web_browser)|Links]]<ref>{{cite web|url=http://links.twibright.com/download/ChangeLog|title=Links ChangeLog: Support lzip compression|access-date=22 July 2025}}</ref>
*[[Lempel–Ziv–Markov_chain_algorithm|lzma]] – compression based on (raw) LZMA is available in Opera 20, and in elinks via a compile-time option<ref>[http://elinks.or.cz/documentation/html/manual.html-chunked/ch01s07.html#CONFIG-LZMA elinks LZMA decompression]</ref>
*peerdist<ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/dd304322%28v=PROT.10%29.aspx|title=[MS-PCCRTP]: Peer Content Caching and Retrieval: Hypertext Transfer Protocol (HTTP) Extensions|publisher=Microsoft|access-date=19 April 2014}}</ref> – Microsoft Peer Content Caching and Retrieval
*[[rsync]]<ref>{{cite web |title=rproxy: Protocol Definition for HTTP rsync Encoding |url=https://rproxy.samba.org/doc/protocol/protocol.html |website=rproxy.samba.org}}</ref>
*xpress
*[[XZ Utils|xz]]
==Servers that support HTTP compression==
Line 62 ⟶ 58:
*[[Internet Information Services|Microsoft IIS]]: built-in or using third-party module
*[[Apache HTTP Server]], via '''[https://httpd.apache.org/docs/current/mod/mod_deflate.html mod_deflate]''' (despite its name, only supporting gzip<ref>{{cite web|url=http://httpd.apache.org/docs/2.4/mod/mod_deflate.html#supportedencodings|title=mod_deflate - Apache HTTP Server Version 2.4 - Supported Encodings}}</ref>), and '''[https://httpd.apache.org/docs/current/mod/mod_brotli.html mod_brotli]'''
*[[Hiawatha (web server)|Hiawatha HTTP server]]: serves pre-compressed files<ref>{{cite web|url=http://www.hiawatha-webserver.org/manpages|title=Extra part of Hiawatha webserver's manual|access-date=2012-01-25|archive-date=2016-03-22|archive-url=https://web.archive.org/web/20160322103000/https://www.hiawatha-webserver.org/manpages|url-status=dead}}</ref>
*[[Cherokee (Webserver)|Cherokee HTTP server]], On the fly gzip and deflate compressions
*[[Oracle iPlanet Web Server]]
Line 77 ⟶ 73:
*[[HAProxy]]
*[[Varnish (software)|Varnish]] – built-in. Works also with [[Edge Side Includes|ESI]]
*[https://line.github.io/armeria/ Armeria] – Serving pre-compressed files<ref>{{cite web|url=https://line.github.io/armeria/server-http-file.html#serving-pre-compressed-files|title=Serving static files part of Armeria's documentation|access-date=2020-01-16|archive-date=2020-04-02|archive-url=https://web.archive.org/web/20200402003001/https://line.github.io/armeria/server-http-file.html#serving-pre-compressed-files|url-status=dead}}</ref>
*[[NaviServer]]
*[[Caddy (web server)|Caddy]] – built-in via [https://caddyserver.com/docs/caddyfile/directives/encode encode]
Many [[content delivery network]]s also implement HTTP compression to improve speedy delivery of resources to end users.
Line 84 ⟶ 81:
The compression in HTTP can also be achieved by using the functionality of [[server-side scripting]] languages like [[PHP]], or programming languages like [[Java (programming language)|Java]].
Various online tools exist to verify a working implementation of HTTP compression. These online tools usually request multiple variants of a URL, each with different request headers (with varying Accept-Encoding content). HTTP compression is considered to be implemented correctly when the server returns a document in a compressed format.<ref>{{ cite
==Problems preventing the use of HTTP compression==
A 2009 article by Google engineers Arvind Jain and Jason Glasgow states that more than 99 person-years are wasted<ref name="google-use-compression">{{cite web|url=https://developers.google.com/speed/articles/use-compression|title=Use compression to make the web faster|access-date=22 May 2013|publisher=Google
Another problem found while deploying HTTP compression on large scale is due to the '''
==Security implications==
Line 106 ⟶ 103:
==External links==
*
*{{IETF RFC|9110|link=no}}: HTTP Semantics
*[https://www.iana.org/assignments/http-parameters HTTP Content-Coding Values] by Internet Assigned Numbers Authority
*[http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:Modcompress Compression with lighttpd]
*[http://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html Coding Horror: HTTP Compression on IIS 6.0] {{Webarchive|url=https://web.archive.org/web/20140206020708/http://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html |date=2014-02-06 }}
*{{webarchive |url=https://web.archive.org/web/20110716033901/http://www.15seconds.com/Issue/020314.htm |date=July 16, 2011 |title=15 Seconds: Web Site Compression }}
*[http://www.serverwatch.com/tutorials/article.php/3514866 Using HTTP Compression] {{Webarchive|url=https://web.archive.org/web/20160314155152/http://www.serverwatch.com/tutorials/article.php/3514866 |date=2016-03-14 }} by Martin Brown of Server Watch
*[https://web.archive.org/web/20060411174003/http://www.devshed.com/c/a/PHP/Using-HTTP-Compression-in-PHP-Make-Your-Web-Pages-Load-Faster/ Using HTTP Compression in PHP]
*[https://web.archive.org/web/20120430023716/https://banu.com/blog/38/dynamic-and-static-http-compression-with-apache-httpd/ Dynamic and static HTTP compression with Apache httpd]
|