Commit 9d515ed
Apply stale-while-revalidate also for responses without a validator
Due to its name, the stale-while-revalidate Cache-Control extension
might suggest that it only applies to revalidation requests. However,
looking at https://tools.ietf.org/html/rfc5861#section-3...
> The stale-while-revalidate Cache-Control Extension
> When present in an HTTP response, the stale-while-revalidate
> Cache-Control extension indicates that caches MAY serve the
> response in which it appears after it becomes stale, up to the
> indicated number of seconds.
> stale-while-revalidate = "stale-while-revalidate" "=" delta-seconds
> If a cached response is served stale due to the presence of this
> extension, the cache SHOULD attempt to revalidate it while still
> serving stale responses (i.e., without blocking).
There is no reason why a cache should not also return a stale response
while a complete re-fetch happens in the background (just what would
happen if validation fails).
This makes a difference if, for example, a resource has
`Cache-Control: public, max-age=30, stale-while-revalidate=30` set and
no additional Last-Modified or ETag headers.
Co-Authored-By: Philip Hofstetter <phofstetter@sensational.ch1 parent 9e6f5eb commit 9d515ed
File tree
3 files changed
+57
-14
lines changed- src
- tests
3 files changed
+57
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
168 | | - | |
| 167 | + | |
| 168 | + | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
171 | 182 | | |
172 | | - | |
| 183 | + | |
| 184 | + | |
173 | 185 | | |
174 | 186 | | |
175 | 187 | | |
176 | 188 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| |||
162 | 167 | | |
163 | 168 | | |
164 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
165 | 205 | | |
166 | 206 | | |
167 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
0 commit comments