Skip to content

Ledger REST API Cache friendliness improvements #2513

@citizen-stig

Description

@citizen-stig

LedgerDb effectively have 2 types endpoints:

  • "live" which should never be cached.
    • /ledger/slots/latest
    • /aggregated-proofs/latest/
  • historical, that can be cached forever (for instant finality, or after finalization):
    • /ledger/slots/{slotId}
    • /ledger/txs/{txId}
    • etc..

Currently no Cache-Control headers are set, leaving caching behaviour undefined for clients and intermediaries (CDNs, reverse proxies).

HTTP Header Reference

Historical endpoints

Cache-Control: public, max-age=31536000, immutable
  • public — cacheable by CDNs and shared proxies, not just the browser
  • max-age=31536000 — 1 year in seconds (practical "forever")
  • immutable — tells clients: don't bother revalidating, this URL's content will never change. Only valid for content-addressed URLs (by hash). Do not use on height-based routes.

Live endpoints

Cache-Control: no-store

no-store — strongest option; response must not be written to any cache at any layer. Prefer this over no-cache (which still stores but revalidates) since stale ledger state is actively harmful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions