Agreeing on compression
How does the server know that the browser can accept compressed content? And how does the browser know that the content it received is compressed?
When a browser that supports compression sends a request to the server, it includes the request header Accept-Encoding
, telling the server which compression algorithms it supports. For example:
Accept-Encoding: gzip,deflate
If the server then uses compression for its response, it includes the response header Content-Encoding
in the (uncompressed) file header to say how the file has been compressed, as shown:
Content-Encoding: gzip
This keeps the browser and server in sync compression-wise. However, as described in Chapter 5, Caching, the Proxy caching section, it isn't only browsers and servers that send and receive requests and responses, but proxies as well. And, proxies can cache responses and serve subsequent requests from their cache. When a proxy caches a compressed file, how do we make sure that the proxy doesn't send...