工作箱POST请求不能为缓存错误

时间:2019-07-05 04:43:32

标签: service-worker workbox

我一直在尝试缓存POST API响应。我已经定义了如下路线。但是它给出了以下错误。我阅读了他们确实支持POST的文档。

https://developers.google.com/web/tools/workbox/modules/workbox-routing#defining_a_route_for_non-get_requests

importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js');

workbox.core.skipWaiting();
workbox.core.clientsClaim();

workbox.routing.registerRoute(
   new RegExp(/.*DataManagement\/GetAllName/),
   new workbox.strategies.StaleWhileRevalidate({
     cacheName: 'api-cache'
   }),
   'POST'
);

enter image description here

离线后,我刷新页面,API调用失败,并显示以下错误

workbox Using StaleWhileRevalidate to respond to 'http://123.22.123.111/DataManagement/GetAllName'
logger.mjs:44 No response found in the 'api-cache' cache. Will wait for the network response.

0 个答案:

没有答案