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

Clarification Added: req-fresh.md5 #1349

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions _includes/api/en/4x/req-fresh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 weather the response is still "fresh" in the client's cache or not, 2 Tags will be used ETag and If-None-Match, ETag will be fetched from response (saved internally from application) and other tag will be recieved from client's request.
gulgulia17 marked this conversation as resolved.
Show resolved Hide resolved

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
Copy link
Member

Choose a reason for hiding this comment

The 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.
users do not need to manage or store timestamps to get etags working, so I think this will confuse people

// may use a file to store timestamps with API request name

res.set('ETag', "foo")
Copy link
Member

Choose a reason for hiding this comment

The 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
```