Replies: 1 comment
-
|
I also did a PoC to add the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
ℹ️ Original message was posted here: https://community.nginx.org/t/nginx-proxy-caching-missing-age-header/5589
My issue:
We are running nginx as an API gateway in a multi-layer caching infrastructure. API calls from clients have to pass trough 2 layers of cache, namely:
The cache feature on nginx is missing the
Ageheader when serving assets from its cache, not respecting RFC 7234 section 4.2.3.As per the RFC, this header helps cloudflare (downstream client) to calculate the time left to cache the assets on its side. However, this header not being present causes sometimes cloudflare to cache the assets for twice the max-age set in the
Cache-Controlheader.Nginx also does not take into account the
Ageheader it receives from upstream when calculating the left max-age to cache assets.How I encountered the problem:
Some assets on cloudflare could be cached for a maximum of twice the max-age when the
Ageheader is missing and depending on when cloudflare is asking for the assets to nginx.Nginx as well might store the assets loner than expected, not considering upstream Àge` header which tells him how long the upstream cache stored the asset already.
Version of NGINX or NGINX adjacent software
1.27
Deployment environment:
Docker compose environment
Nginx configuration
#1 Nginx caching the asset and not sending
AgeheaderUsing the curl container we issue the following commands
Nginx is not sending any
Ageheader to the downstream during a HIT. We have no way of knowing how long the asset's time has left.#2 Nginx caching the asset and not respecting upstream
AgeheaderUsing the curl container we issue the following commands
Here even if we issue the 3rd curl 5s after the 2nd curl we still have a HIT. However nginx should have computed the
Ageheader sent by the upstream and only cached the assets for 10 - 9 = 1s.Ideas
It would be a nice to have the
Agesupport in the nginx OSS for both use cases:Ageheader to calculate the asset's freshnessAgeheader on a cache HITBeta Was this translation helpful? Give feedback.
All reactions