nginx/nginx
Ver no GitHubImprove handling of Age header with $upstream_cache_age
Open
#1.234 aberto em 31 de mar. de 2026
enhancementfeaturegood first issuerefined
Métricas do repositório
- Stars
- (30.331 stars)
- Métricas de merge de PR
- (Mesclagem média 27d 8h) (17 fundiu PRs em 30d)
Description
Feature Overview
A new variable $upstream_cache_age was introduced to reflect response age, including:
- Time spent in cache
- Upstream response age from the Age header
- If not cached, it reflects the upstream Age header directly
This enables use cases aligned with the HTTP/1.1 caching model, for example:
add_header Age $upstream_cache_age;
Problem:
Current behavior has unintended side effects:
- Age header is removed when using: add_header Age $upstream_cache_age
- expires directive removes the existing Age header Assumes zero age when setting Expires and Cache-Control
This leads to:
- Loss of upstream-provided Age information
- Incorrect cache semantics from a client perspective
- Deviation from standard HTTP caching behavior
Expected Behavior
- Preserve upstream Age header unless explicitly overridden
- Allow $upstream_cache_age to:
- Override OR
- Extend existing Age header (configurable behavior)
References Changeset: https://freenginx.org/hg/nginx/rev/e46e1ea89ccd Additional: https://freenginx.org/hg/nginx/rev/8cdab3d89c44