Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache: fix stale-while-revalidate and stale-if-error #3865

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

flakey5
Copy link
Member

@flakey5 flakey5 commented Nov 22, 2024

Closes #3853

This cleans up the cache interceptor file. This also makes the cache stores store the responses' cache control directives. This was the nicest way I could think of to implement stale-if-error and also sets it up nicely for if we ever allow for more cache control directive extensions.

@mcollina mcollina requested review from ronag and metcoder95 November 22, 2024 10:59
lib/interceptor/cache.js Outdated Show resolved Hide resolved
@metcoder95
Copy link
Member

types seems to be failing

@flakey5 flakey5 force-pushed the flakey5/20241120/3852 branch from c1bd909 to 835ade3 Compare November 22, 2024 16:34
@ronag
Copy link
Member

ronag commented Nov 23, 2024

@flakey5 can you rebase?

*/
constructor (callback, handler) {
constructor (callback, handler, allowErrorStatusCodes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For stale-if-error, error status codes when revalidating mean to use the stale response

@flakey5 flakey5 force-pushed the flakey5/20241120/3852 branch from 835ade3 to 45c0793 Compare November 24, 2024 03:02
@flakey5 flakey5 force-pushed the flakey5/20241120/3852 branch from 45c0793 to 10c87fd Compare November 25, 2024 15:40
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are plenty of merge errors

lib/handler/cache-revalidation-handler.js Outdated Show resolved Hide resolved
lib/handler/cache-revalidation-handler.js Outdated Show resolved Hide resolved
@flakey5 flakey5 force-pushed the flakey5/20241120/3852 branch from 10c87fd to 1f61576 Compare November 25, 2024 16:53
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Closes nodejs#3853

Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
@flakey5 flakey5 force-pushed the flakey5/20241120/3852 branch from 1f61576 to fa398ba Compare November 25, 2024 16:55
@flakey5 flakey5 requested a review from ronag November 25, 2024 17:24
test/types/cache-interceptor.test-d.ts Outdated Show resolved Hide resolved
test/interceptors/cache.js Outdated Show resolved Hide resolved
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 71b6b0b into nodejs:main Nov 25, 2024
37 checks passed
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cache: Implement stale-while-revalidate and stale-if-error
4 participants