Observe compression negotiation

Observe how Accept-Encoding, Content-Encoding, and Vary participate in one bounded response.

  • negotiation
  • compression
  • representations

Prediction

The server can select gzip when acceptable and identity otherwise, while Vary: Accept-Encoding tells caches which request field affected selection.

Controlled observation

The future view will distinguish transfer coding metadata, compressed byte count, and decoded content for one fixed representation.

Explanation

Content-Encoding describes coding applied to the representation. Browser APIs normally expose decoded content, so displayed text length is not wire transfer size.

Controlled exercise

Run this observation

Use the generated cURL example: browser Fetch forbids setting Accept-Encoding and reports decoded content, not reliable wire bytes.

Browser run unavailable for this wire-level observation; use a portable example below.

Ready. No request has run.

Controlled request

Method
GET
URL
https://lab.httpclarity.com/v1/compression
Permitted headers
Accept-Encoding: identity
Body
None

Browser-observed response

No response yet. The explanation and examples remain useful without JavaScript or the Worker.

Timing is browser elapsed time. Fetch hides Set-Cookie, raw wire bytes, reliable compressed size, and some redirect details.

Portable examples

cURL

              'curl' '--include' '--request' 'GET' '--header' 'Accept-Encoding: identity' 'https://lab.httpclarity.com/v1/compression'
            

Fetch API

              // Browser Fetch cannot reproduce this wire-level request.
// Use the cURL or PHP example instead.
            

PHP

              <?php
$options = ['http' => [
    'method' => 'GET',
    'ignore_errors' => true,
    'header' => 'Accept-Encoding: identity',
]];
$context = stream_context_create($options);
$body = file_get_contents('https://lab.httpclarity.com/v1/compression', false, $context);
var_dump($http_response_header, $body);
            

Need a full API client? Copy the generated cURL command, then import it in Hoppscotch. HTTPClarity sends no request data to Hoppscotch.

Continue in Hoppscotch (opens in a new tab)

Primary sources