Comments (8)
Hmm, actually I probably need to add the RangeRequests plugin to the precaching handler... So that runtimeCachine example from the linked article isn't helpful for that...
from workbox.
Doesn't seem to help even if I do that though...
from workbox.
I guess a workaround will be to do preload="none"
and hope the user doesn't start any media before pre-caching ends... There doesn't seem to be an obvious way to add plugins to workbox-precaching
in generateSW
mode of workbox-build
which I opened a separate request for #3289.
I guess a fix will be to just let such requests through to the network, without trying to precache from their response, letting the normal pre-caching still take place, or alternatively to outright to dump the Range
header when getting a request that has it during the install
phase in the PrecachingStrategy
, and maybe also pass the response through plugins so the ranges plugin can modify the complete response to only return the requested range even in that case.
from workbox.
Maybe we want something like this in the range requests plugin or inside workbox-precaching
:
// requestWillFetch() if from a plugin
if (handler.event && handler.event.type === 'install') {
request.headers.delete("Range")
}
from workbox.
Doesn't work. The headers
received in the request object seem empty for this case...
from workbox.
We probably need to add 206 to be ignored here:
from workbox.
Doesn't help, still leads to bad-precaching-response
.
from workbox.
So basically the browser sets a Range: bytes=0-
header with preload="auto"
and gets a full response with a 206 status, when the service worker starts after that request is complete, and tries to prefetch the file, the browser returns the 206 full content response (Racy, due to chromium coalescing the requests) which fails to be inserted into the cache with the described error. Something like this can possibly fix this:
async cacheWillUpdate({ response }) {
// The default will update logic of workbox-precaching
if (!response || response.status >= 400) {
return null;
}
if (response.status === 206 /* && fullBody */) {
console.log('Patching 206 response');
response = await copyResponse(response, (responseInit) => {
responseInit.status = 200;
return responseInit;
})
}
return response;
},
But I think copyResponse
will fail if the request is cross origin...
from workbox.
Related Issues (20)
- non-precached-url :: [{"url":"/"}]
- Long queue time on the initial index.html request during SW update with heavy precache HOT 1
- typo
- new method for custom plugins called "" HOT 2
- new "cachedResponseIsAbsent" method for custom plugins
- Is this project not maintained anymore? HOT 3
- Please Sign the Open Letter to Tim Cook: Sabotaging Web Apps Is Indefensible HOT 2
- [email protected] is deprecated HOT 2
- Google fonts sometimes fail to load - caching of opaque errors
- Split code for the Workbox library when using the `InjectManifest` class
- I cannot see the workbox pre-cached database in the Safari browser HOT 1
- CacheableResponse should accept an array of header values
- Precaching doesn't work properly in Safari when offline
- Consider adding `maxUnusedSeconds` and `updateStale` to `ExpirationPlugin` config
- Standardize behavior of `maxAgeSeconds`
- Update Node version on Glitch demos
- Support wasm files by default in globPatterns
- CVE-2021-23337 Command Injection in lodash
- [docs] Wrong menu label for page "Retrying requests when back online"
- Minimum rollup version isn't high enough for @rollup/plugin-node-resolve
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workbox.