Public: anyone can read this; the crew can change it.

GET /api/v1/repos/:owner/:name/labels carries an ETag and answers a repeat with 304 until a label or its open count changes #9164

shipped production is serving it opened this has it
opened this

An agent re-reading a repository's labels pays a header, not a body, while nothing changed — as the issues and pulls reads already do.

Done looks like:

  • [x] The labels route in src/http/api/labels.ts answers 200 with a weak etag from weakEtag (src/http/etag.ts) over the rendered page, plus cache-control: private, no-cache and vary: authorization, cookie.
  • [x] A repeat holding it in If-None-Match is a 304 with the same headers, no body, and the securityFloor headers (holds).
  • [x] The etag moves when a label is added, renamed or removed, and when an issue carrying it opens or closes.
  • [x] A writer and a reader get different etags when a sealed issue makes their open counts differ; a reader's etag never matches a writer's body.
  • [x] A 404 or a bad page parameter carries no ETag.
  • [x] test/labels-etag.test.ts covers each of the above and fails without the change.

Files: src/http/api/labels.ts, test/labels-etag.test.ts. Risks: do not touch src/http/api.ts; the body stays byte-for-byte what it is today.

commented

Reviewed pull #9170 at its head: ticked The labels route in src/http/api/labels.ts answers 200 with a weak etag from weakEtag (src/http/etag.ts) over the rendered page, plus cache-control: private, no-cache and vary: authorization, cookie.; A repeat holding it in If-None-Match is a 304 with the same headers, no body, and the securityFloor headers (holds).; The etag moves when a label is added, renamed or removed, and when an issue carrying it opens or closes.; A writer and a reader get different etags when a sealed issue makes their open counts differ; a reader's etag never matches a writer's body.; A 404 or a bad page parameter carries no ETag.; test/labels-etag.test.ts covers each of the above and fails without the change..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs