Skip to content

REST: support ?max-age=<seconds> TTL override on @table resources (not just isCaching) #1226

Description

@kriszyp

Summary

The ?max-age=<seconds> query parameter for overriding a record's TTL at write time is not implemented for regular @table(expiration:) resources. It only works for isCaching resources via the Cache-Control: max-age request header.

Current behavior

PUT/POST to a regular @table(expiration: N) resource ignores any ?max-age=<value> query parameter. The record always expires at the table-level default.

Desired behavior

A writer can override the TTL on a per-record basis:

PUT /ShortLived/item1?max-age=600  →  record expires in 600s regardless of table default

This is analogous to HTTP cache semantics where the origin can set a per-response TTL.

Motivation

Found while writing integration tests for fleet-informed test plan (#1191). Production clusters use this pattern:

  • Walmart USGM redirect service uses ?max-age=<seconds> to set per-redirect expiry at write time (overriding the 1-year table default)

Implementation notes

The hook point is in server/REST.ts: the isCaching branch already parses cache-control: max-age for caching resources. The @table resource path would need to read req.query['max-age'] and apply it as the record's expiresAt.

The existing expiration table attribute and ?max-age header form both ultimately set expiresAt on the record — this is about exposing that same mechanism via query parameter for any table type.

Tracking

Placeholder test exists in integrationTests/apiTests/ttl.test.ts (test 3, marked TODO).

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

Metadata

Metadata

Assignees

Labels

area:rest-apiREST API, resources, routingenhancementNew feature or request

Fields

Priority

P2

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions