-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
flutter_service_worker.js seems to cache the response even if the response is 4XX/5XX error.
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_system/targets/web.dart#L669
And, the service worker caches the response during the resource's hash is identical.
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_system/targets/web.dart#L616
As a result, the service worker still uses the cache of the error response after the error is recovered, because the target resource's hash is not changed.
Is it expected behavior? Or, should the cacheing strategy be improved?
Steps to Reproduce
- Request to some static resource e.g.
.jsfile - The request failed with an error
- In my case it is 401 Basic Authentication failure, but I think the same thing will occur in other situation e.g. CDN is down.
- The error response is cached by flutter service worker
- Recovered from the error
- Request to the target resource again
Expected results:
The resource file is loaded successfully
Actual results:
The cached error is still returned by the service worker