Skip to content

Heuristic freshness computed from Last-Modified #3

Description

@knoan

challenge / use case

A response stating no explicit expiration is revalidated on every exchange, even where it carries a Last-Modified
field that says how volatile the content actually is. An origin whose content has not changed in a year is re-fetched
as eagerly as one edited a minute ago.

proposal

Derive a freshness lifetime from the response header fields where the origin states no explicit expiration, as
permitted by RFC 9111 § 4.2.2: take the interval since Last-Modified and treat a fraction of it as the lifetime,
around 10% as the RFC encourages.

Guards:

  • apply only where no Cache-Control freshness directive and no Expires is stated; no-cache and max-age=0 are
    stated expirations and must keep winning, so the test is whether a directive is present, not whether the computed
    lifetime is 0
  • apply only for the heuristically cacheable status codes of RFC 9110 § 15.1
  • bound the result, so a distant Last-Modified does not yield an unbounded lifetime
  • let ttl cap the result as it caps any computed lifetime

alternatives

Leaving it to the consumer to state a flat lifetime. That covers an origin stating nothing at all, but ignores the
volatility an origin does state, so a stable and a churning resource are reused for the same span.

notes

Ranks between the two cases already settled: a stated expiration wins over this, and this wins over a flat lifetime
the consumer states for an origin whose responses carry no Last-Modified either.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions