fix(service-worker): cache opaque responses in data groups with freshness
strategy (#30977)
Previously, (presummably due to a typo) the `okToCacheOpaque` argument of `DataGroup#cacheResponse()` was essentially never taken into account (since opaque responses have a non-200 status code and thus `res.ok` is always false). This commit fixes the typo, which allows opaque responses to be cached when `okToCacheOpaque` is true (i.e. in data groups using the `freshness` strategy). Fixes #30968 PR Close #30977
This commit is contained in:

committed by
Alex Rickabaugh

parent
2d38623974
commit
d7be38f84b
@ -481,10 +481,10 @@ export class DataGroup {
|
||||
* If the request times out on the server, an error will be returned but the real network
|
||||
* request will still be running in the background, to be cached when it completes.
|
||||
*/
|
||||
private async cacheResponse(
|
||||
req: Request, res: Response, lru: LruList, okToCacheOpaque: boolean = false): Promise<void> {
|
||||
private async cacheResponse(req: Request, res: Response, lru: LruList, okToCacheOpaque = false):
|
||||
Promise<void> {
|
||||
// Only cache successful responses.
|
||||
if (!res.ok || (okToCacheOpaque && res.type === 'opaque')) {
|
||||
if (!(res.ok || (okToCacheOpaque && res.type === 'opaque'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user