Skip to content

Feature request: Revalidation of expired items in cache #181

@srikiraju

Description

@srikiraju

Hello,
I was looking for a specific type of behaviour in a cache system for nginx. Specially, I want this behaviour.

Request 1)

Web-client GET /foo
Nginx: Forward to origin
Response: 200, Etag: "baws", Cache-control: max-age:30, stale-while-response: 200000(or whatever)

Time passes. 35 seconds gone.
Request 2)
Web-client2 GET /foo
Nginx: Cache expired. Does a FULL request to origin to get the whole object. This does not include the "If-None-Match" validator. Returns 200, with Etag: baws"

What I expect
Web-client2 GET /foo
Nginx: Cache expired. Does a Conditional request to origin using If-None-Match. If it gets a 304 from origin, returns the whole thing with a 200 to client(since the client did not include an If-None-Match. Otherwise, it refreshes the cached version and returns that 200 to the origin. This is significantly more optimal (in my specific use case). Note that this means the upstream application isn't always computing the whole response.

This is extremely annoying since its forcing my origin to recompute something heavy.

BTW, Nginx totally does the thing I was want using the "proxy_cache_revalidate" feature, but I require a shared cache for my application.

Any idea on if this will be easy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions