Observe cache freshness

Observe the difference between a fresh stored response and one that requires another cache decision.

  • caching
  • freshness

Prediction

A fresh stored response can be reused without validation; after freshness expires, the cache needs another permitted reuse or validation decision.

Controlled observation

The future scenario will expose a fixed version, generation time, max-age, and age so the user can distinguish freshness from content version.

Explanation

Storage, matching, freshness, and reuse are separate decisions. One cached label cannot explain all four.

Controlled exercise

Run this observation

Run twice within ten seconds, then after expiry; compare generation time and request ID.

Ready. No request has run.

Controlled request

Method
GET
URL
https://lab.httpclarity.com/v1/cache-freshness
Permitted headers
None
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' 'https://lab.httpclarity.com/v1/cache-freshness'
            

Fetch API

              const response = await fetch("https://lab.httpclarity.com/v1/cache-freshness", {
  "method": "GET"
});
console.log(response.status, await response.text());
            

PHP

              <?php
$options = ['http' => [
    'method' => 'GET',
    'ignore_errors' => true,
]];
$context = stream_context_create($options);
$body = file_get_contents('https://lab.httpclarity.com/v1/cache-freshness', 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