Enhance Response cache-control header
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Bereich
- api, documentation
Rechercherichtung
Beginnen Sie mit der Prüfung von OpenAPI Header Object, der JSON-Schema-Unterstützung und den Cache-Control-Beispielen in diesem Issue. Es sind keine Repository-Dateien oder Tests angegeben; für die Fertigstellung müsste man sich auf eine präzise, interoperable Art einigen und diese dokumentieren, um durch Kommas getrennte Direktiven und Schlüssel-Wert-Direktiven wie max-age darzustellen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I have been trying to use Open API to specify the expected Cache rules for some API routes
While defining such rules through the Expires and/or Pragma headers can be quite simple (a date for Expires & the no-cache constant for Pragma), they are not the modern way to do it. Pragma is deprecated, and Expires is ignored when Cache-Control is defined.
Cache-Control is also nowadays supported by all clients making it the most obvious solution to define the caching rules.
Unfortunately, the current OPEN API Header Object support looks a bit limited for Cache-Control. Using pure JSON Schema definition might produce unexpected behavior without dedicated context for this header or for headers having similar Design.
This header value is defined as a comma-seperated list of properties called directives
If all directives were simple strings I could write something like that if I allowed any of them (or restrict to the on I accept by design)
responses:
200:
description: "The request was successfully treated."
headers:
Cache-Control:
schema:
type: array
items:
type: string
enum:
- public
- private
- no-cache
- no-store
- must-revalidate
- proxy-revalidate
- immutable
- no-transform
- only-if-cached
If I want my route to prevent response to be cached I can easily design it a more simple way
Cache-Control:
schema:
type: string
enum:
- no-store
Or with the last JSON-Schema edition support of constants
Cache-Control:
schema:
const: "no-store"
But some of the most important cache control properties are key value pairs like max-age=300
I tried to express it the most reiable still simple way using adavanced JSON Schema feature unfortunately not really well supported (yet?) by Open API implementations
Sample 1
- Pro:
- shortest
- Cons:
- forbid different property order
- forbid potentially acceptable other cache-control properties
- not really the most inspectable
Cache-Control:
schema:
const: "public, max-age=300"
Sample 2
- Pro:
- still short
- Cons:
- ⚠️❌ the specification doesn't say how to serialize the object
Cache-Control:
schema:
const: ["public", {"max-age": 300}]
Sample 3
- Pro:
- explicit, no need for const support
- Cons:
- very verbose
- pretty sure enum not well supported for numbers
- ⚠️❌ the specification still doesn't say how to serialize the object
Cache-Control:
schema:
type: array
items:
allOf:
- type: string
enum:
- public
- type: object
properties:
max-age:
type: number
enum:
- 300
required:
- max-age
- Vorherrschende Sprache
- Markdown
- Sterne
- 31.2k
- Forks
- 9.2k
- Ø Merge
- 2 T. 9 Std.
- Gemergte PRs (30 T.)
- 17
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus OAI/OpenAPI-Specification
-
Housekeeping
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 45/100
OAI/OpenAPI-Specification#5566 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Housekeeping
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 35/100
OAI/OpenAPI-Specification#5562 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Housekeeping
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 10/100
OAI/OpenAPI-Specification#5556 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
v3.2.1 releaseEvtl. wieder frei @lornajane hat das vor 32 Tagen übernommen, und es ist kein Pull Request offen. Offen
OAI/OpenAPI-Specification#5460 · 11 Kommentare · 1 Reaktion · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
param serialization
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
OAI/OpenAPI-Specification#5366 · 12 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in OAI/OpenAPI-Specification
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
better-auth/better-auth#11723 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement from-review
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
khuisman/mcp-gee-sweet#1010 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Worker-Erstellung bricht langsame Git-Worktree-Checkouts nach 20 Sekunden abEvtl. vergeben @KajoVanBuyten hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
AgentSystemLabs/agent-office#367 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: backend bug priority: high
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
snapotter-hq/SnapOtter#2423 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area::tern difficulty::easy good first issue kind::bug triage::ready
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100