Enhance Response cache-control header
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- À clarifier
- Activité
- À l'abandon
- Domaine
- api, documentation
Piste de recherche
Commencez par examiner OpenAPI Header Object, la prise en charge de JSON Schema et les exemples de Cache-Control dans cette issue. Aucun fichier du dépôt ni aucun test n’est identifié ; la finalisation nécessiterait de convenir d’une manière précise et interopérable de représenter les directives séparées par des virgules et les directives clé-valeur telles que max-age, puis de la documenter.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Markdown
- Étoiles
- 31.2k
- Forks
- 9.2k
- Merge moyen
- 2 j 9 h
- PR mergées (30 j)
- 17
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de OAI/OpenAPI-Specification
-
Housekeeping
Difficulté 1/5 Moins d'une heure Accessibilité débutants 45/100
OAI/OpenAPI-Specification#5566 ·
Les mainteneurs répondent en général sous 1 jour
-
Housekeeping
Difficulté 1/5 Moins d'une heure Accessibilité débutants 35/100
OAI/OpenAPI-Specification#5562 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Housekeeping
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 10/100
OAI/OpenAPI-Specification#5556 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
v3.2.1 releasePeut-être à nouveau libre @lornajane l’a pris il y a 32 jours, et aucune pull request n’est ouverte. Ouverte
OAI/OpenAPI-Specification#5460 · 11 commentaires · 1 réaction · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
param serialization
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
OAI/OpenAPI-Specification#5366 · 12 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de OAI/OpenAPI-Specification
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
huggingface/smolagents#2976 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
FuRongJun-1999/dsh-memory#170 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement minor
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
testcontainers/testcontainers-node#1539 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
backdrop-contrib/commerce#60 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 76/100