what happens if the max-age
is zero but stale-while-revalidate
has a value?
example: Cache-Control: max-age=0, stale-while-revalidate=60
will the stale-while-revalidate
be taken into consideration at all? or the origin will be hit every time for the data?
A request would be sent to the origin every time.
stale-while-revalidate
allows the client to use a stale response--while it revalidates with origin--if the response's age is less than max-age
+ stale-while-revalidate
.
Here's a scenario using Cache-Control: max-age=0, stale-while-revalidate=60
:
A user lands on a page and then refreshes the page.
The response is immediately stale because max-age=0
but its age
is within the still-usable window of time (i.e max-age + stale-while-revalidate
).
The client loads the stale response and sends a request to the origin to revalidate it.