Enhance Response cache-control header
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Funcionalidade
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Domínio
- api, documentation
Direção de pesquisa
Comece revisando OpenAPI Header Object, o suporte a JSON Schema e os exemplos de Cache-Control nesta issue. Nenhum arquivo do repositório ou teste foi identificado; a conclusão exigiria concordar e documentar uma forma precisa e interoperável de representar diretivas separadas por vírgulas e diretivas de chave-valor, como max-age.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Markdown
- Estrelas
- 31.2k
- Forks
- 9.2k
- Merge médio
- 2d 9h
- PRs com merge (30d)
- 17
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de OAI/OpenAPI-Specification
-
Housekeeping
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 45/100
OAI/OpenAPI-Specification#5566 ·
Mantenedores costumam responder em até 1 dia
-
Housekeeping
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 35/100
OAI/OpenAPI-Specification#5562 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Housekeeping
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 10/100
OAI/OpenAPI-Specification#5556 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
v3.2.1 releaseTalvez livre de novo @lornajane assumiu há 32 dias e não há nenhum pull request aberto. Aberta
OAI/OpenAPI-Specification#5460 · 11 comentários · 1 reação · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
param serialization
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
OAI/OpenAPI-Specification#5366 · 12 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de OAI/OpenAPI-Specification
Issues semelhantes
-
bug help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
[BUG] 增量 SSE 解析器未识别单独 CR 换行,导致事件无法及时交付Talvez já em andamento @king-wwwhhh assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
langchain4j/langchain4j#6669 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
microsoft/playwright#43327 ·
Mantenedores costumam responder em até 1 dia
-
Rename FunctionalRole BOT_DEV to DEV_STAFFTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertaenhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
pesu-dev/discord_bot#97 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/TypeScript#64758 ·
Mantenedores costumam responder em até 1 dia