-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Clarification Added: req-fresh.md5 #1349
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,19 @@ | |
|
||
When the response is still "fresh" in the client's cache `true` is returned, otherwise `false` is returned to indicate that the client cache is now stale and the full response should be sent. | ||
|
||
In order to check whether the response is still "fresh" in the client's cache or not, two tags will be used ETag and If-None-Match. ETag will be fetched from response (saved internally from application) and other tag will be received from client's request. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @gulgulia17,
|
||
|
||
When a client sends the `Cache-Control: no-cache` request header to indicate an end-to-end reload request, this module will return `false` to make handling these requests transparent. | ||
|
||
Further details for how cache validation works can be found in the | ||
[HTTP/1.1 Caching Specification](https://tools.ietf.org/html/rfc7234). | ||
|
||
```js | ||
|
||
// Get value for ETag where you saved it initially, In general you | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment isn't very clear. The added example is setting an etag not reading a value. |
||
// may use a file to store timestamps with API request name | ||
|
||
res.set('ETag', "foo") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example that existed wasn't very clear to begin with. Setting an etag here doesn't mean that req.fresh will be true, so the example gets less clear with the addition. It's easier perhaps to demonstrate that setting a new, highly random etag on every request can guarantee that req.fresh is false. That way we create an example which will always have the demonstrated output. |
||
console.dir(req.fresh) | ||
// => true | ||
``` |
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.
The headers which go into determing fresh are seen here in jshttp/fresh