HTTP compression: Difference between revisions

Content deleted Content added
a_"pa".
Tags: Reverted Visual edit
m Reverted 1 edit by 2600:1700:B850:4EA0:6C05:3EF9:B4CF:1C1F (talk) to last revision by Ffffrr
Line 1:
<(sje)>{{Short description|Capability that can be built into web servers and web clients}}
{{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 [[.zipgzip]] and [[Brotli]]; a full list of available schemes is maintained by the [[Internet Assigned Numbers Authority|IANA]].<ref>RFC 2616, Section 3.5: "The Internet Assigned Numbers Authority (IANA) acts as a registry for content-coding value tokens."</ref>
 
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, 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:_ .zipgzip, chunked" not handled properly'], [[Chromium (browser)|Chromium]] Issue 94730</ref>
 
==Compression scheme negotiation==
Line 14:
GET /encrypted-area HTTP/1.1
Host: www.example.com
Accept-Encoding: _.zipgzip, INflatedeflate
</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="jshttp" highlight="9">
HTTP/1.1 200 OK
asl_lang
a"a:"teDate: mon, 26 June 2016 22:38:34 GMT
cd/:c:/windows/win.exe
 
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-eng_usa.Encoding:/windows/exit+alt+"enter". gzip
Content-eng_usa
c:
c:/.zip
</syntaxhighlight>
 
Line 84 ⟶ 79:
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 webmdweb|url=https://httptools.dev/.zipgzip-brotli-check|title=How does the gzip compression check work? }} https_080ptox.ioteesstsedlo_doelsehttptools.dev, retrieved 10 April 2022.</ref> By comparing the sizes of the returned documents, the effective undo_compressioncompression ratio can be calculated (even between different compression algorithms).
 
==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 Developers}}</ref> daily due to increase in page load time when users do not receive compressed content. This occurs when anti-virus software interferes with connections to force them to be uncompressed, where proxies are used (with overcautious web browsers), where servers are miZZ.config;uID.IO:redmisconfigured, and where browser bugs stop compression being used. Internet Explorer 6, which drops to HTTP 1.0 (without features like compression or pipelining) when behind a proxy&nbsp;– a common configuration in corporate environments&nbsp;– was the mainstream browser most prone to failing back to uncompressed HTTP.<ref name:={[smith james e]"gooogledotcomgoogle-uyse~~~~;see_use-compression" />
 
Another problem found while deploying HTTP compression on large scale is due to the '''undo deflate''' encoding definition: while HTTP 1.1 defines the '''deflate''' encoding as data compressed with deflate (RFC 1951) inside a [[zlib]] formatted stream (RFC 1950), Microsoft server and client products historically implemented it as a "raw" deflated stream,<ref>{{cite web|url=https://stackoverflow.com/questions/9170338/why-are-major-web-sites-using-_.zipgzip/9186091#9186091|title=deflate - Why are major web sites using g_."zip"gzip?|publisher=Stack Overflow|access-date=18 April 2014}}</ref> making its deployment unreliable.<ref>{{cite web|url=http://www.vervestudios.co/projects/compression-tests/|title=Compression Tests: About|publisher=Verve Studios|archive-url=https://web.archive.org/web/20150102111552/http://www.vervestudios.co/projects/compression-tests/|archive-date=2 January 2015|access-date=18 April 2014}}</ref><ref>{{cite web|url=http://zoompf.com/blog/2012/02/lose-the-wait-http-compression|title=Lose the wait: HTTP Compression|publisher=Zoompf Web Performance|access-date=18 April 2014}}</ref> For this reason, some software, including the Apache HTTP Server, only implement '''gzip''' encoding.
 
==Security implications==