I am using the code from this site: https://developers.google.com/web/tools/workbox/modules/workbox-routing
My code is as below:
workbox.routing.registerRoute(
new RegExp('http://localhost:64445.*/'),
workbox.strategies.staleWhileRevalidate({
cacheName:'Post-Run-time-cache'
}),
'POST'
);
And it gives me the error:
Uncaught (in promise) TypeError: Request method 'POST' is unsupported
I do not know what went wrong. It is from the document but it is not supported?? why. Thanks for the help.
The Cache Storage API doesn't support using a Request
object whose method
is not 'GET'
as a cache key. Attempting to store a 'POST'
request in the cache (which is happening under the hood in the staleWhileRevalidate
strategy) will fail with an error similar to what you're seeing—though I think there's a more informative error logged when you're in Workbox's development mode, on localhost
.
If you're looking to retry failed 'POST'
requests, I'd recommend the workbox-background-sync
module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With