There's currently no good way to determine whether or not a browser / environment supports GZIP-deflated content entirely from the front-end. Servers can interrogate the
This is important when using a CDN that doesn't facilitate selection of appropriately deflated content (e.g. AWS CloudFront). I've had projects where the initial HTML content is dynamically generated only so that the server can pass the
Accept-Encoding header back to the client. That way, the client can adjust the other URLs it uses to pick pre-GZIPed files, e.g. blah.js.gz instead of blah.js all the time.
I was initially thinking that
navigator.acceptEncoding could just be specified to contain the default outgoing value of this header, but it occurred to me that there are probably other headers where this is handy.
Should this be a function such as
Should all such headers just dangle from the
navigator object as in my previous example?