Skip to content

The cache handler should not invalidate all requests to an origin #3806

@ivan-tymoshenko

Description

@ivan-tymoshenko

When the cache-handler recevies a succesful response from one of "unsafe" http methods such as POST/PUT/DELETE... it invalidates all other cached responses to this origin.

https://github.com/nodejs/undici/blob/main/lib/handler/cache-handler.js#L79

RFC says:

A cache MUST invalidate the target URI ([Section 7.1](https://www.rfc-editor.org/rfc/rfc9110#section-7.1) of [[HTTP](https://www.rfc-editor.org/rfc/rfc9111.html#HTTP)]) when it receives a non-error status code in response to an unsafe request method (including methods whose safety is unknown).

By "target URI" here I understand the the full URL and not just an origin (correct me here if I;m wrong). For example if a client receives a succesful response for the DELETE http://example.com/foo/bar the cache hanlder can delete the GET http://example.com/foo/bar, but not all other cached responses to the http://example.com.

IMHO With a current behaviour the cache seems useless, because a one regulary called POST requests keeps your cache almost always empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions