我一直在尝试缓存POST API响应。我已经定义了如下路线。但是它给出了以下错误。我阅读了他们确实支持POST的文档。
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'
);
离线后,我刷新页面,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.