-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
return no-cache on 404 #2609
return no-cache on 404 #2609
Conversation
group-income
|
Project |
group-income
|
Branch Review |
2608-disable-cache-404
|
Run status |
|
Run duration | 11m 34s |
Commit |
|
Committer | Greg Slepak |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
10
|
|
0
|
|
114
|
View all changes introduced in this branch ↗︎ |
backend/routes.js
Outdated
function notFoundNoCache (h) { | ||
return h.response() | ||
.code(404) | ||
.header('Cache-Control', 'no-store, must-revalidate, proxy-revalidate') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*-revalidate
is redundant as well, since no-store
already means that the response should not be put in a cache to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think the issue here is this, since by default 404 responses will not be cached.
Most commonly, caches store the successful result of a retrieval request: i.e., a 200 (OK) response to a GET request, which contains a representation of the target resource (Section 9.3.1 of [HTTP]). However, it is also possible to store redirects, negative results (e.g., 404 (Not Found)), incomplete results (e.g., 206 (Partial Content)), and responses to methods other than GET if the method's definition allows such caching and defines something suitable for use as a cache key.
cache: {
// Do not set other cache options here, to make sure the 'otherwise' option
// will be used so that the 'immutable' directive gets included.
otherwise: 'public,max-age=31536000,immutable'
}
I'm not too familiar with HAPI, and not with the old version used in GI, but, instead of setting a cache policy and then 'undoing it' with this new notFoundNoCache
wouldn't it be better to simply tell HAPI not to apply the immutable
(or a custom) cache policy to errors?
backend/routes.js
Outdated
.code(404) | ||
.header('Cache-Control', 'no-store, must-revalidate, proxy-revalidate') | ||
.header('Pragma', 'no-cache') | ||
.header('Expires', '0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expires
is supposed to have a timestamp, so 0
isn't a valid value. However, it's not really relevant if cache-control
is present, except for clients that don't support HTTP/1.1. I don't think any such clients exist (today) to any significant, and even if they did, they can be ignored.
backend/routes.js
Outdated
return h.response() | ||
.code(404) | ||
.header('Cache-Control', 'no-store, must-revalidate, proxy-revalidate') | ||
.header('Pragma', 'no-cache') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pragma: no-cache
has never been standard for responses, and is also largely irrelevant for clients that understand cache-control
.
I suggest either of these solutions:
|
Partially addresses #2608.