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 all commits
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 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.
Copy link
Member

@jonchurch jonchurch Mar 8, 2024

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

  • If-None-Match
  • Etag
  • Cache-Control: no-cache
  • If-Modified-Since
  • Last-Modified

Copy link
Contributor

@chrisdel101 chrisdel101 Apr 9, 2024

Choose a reason for hiding this comment

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

Hey @gulgulia17,
@crandmck said I could leave any feedback for your PR. I'm not a maintainer here or anything, so you don't have to listen to me :]. It's all just punctuation related stuff.

  1. Add a colon to this:
    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.
  2. Add a comma in the middle + missing 'the':
    ETag will be fetched from response (saved internally from application), and the other tag will be received from client's request.


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

Check failure on line 13 in _includes/api/en/4x/req-fresh.md

View workflow job for this annotation

GitHub Actions / test

Too many blank lines at the beginning of file. Max of 0 allowed
// Get value for ETag where you saved it initially, In general you

Check failure on line 14 in _includes/api/en/4x/req-fresh.md

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
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")

Check failure on line 17 in _includes/api/en/4x/req-fresh.md

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
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
```
Loading