I tried to cache a POST request in a service worker on fetch event.
I used cache.put(event.request, response)
, but the returned promise was rejected with TypeError: Invalid request method POST.
.
When I tried to hit the same POST API, caches.match(event.request)
was giving me undefined.
But when I did the same for GET methods, it worked: caches.match(event.request)
for a GET request was giving me a response.
Can service workers cache POST requests?
In case they can't, what approach can we use to make apps truly offline?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…