-
Notifications
You must be signed in to change notification settings - Fork 860
Open
Labels
DiscussAn open question, where input from the community would be appreciated.An open question, where input from the community would be appreciated.
Description
I want to customize the cache and cache post requests. How should I modify my code?
StrategyHandler.js:271 Uncaught (in promise) attempt-to-cache-non-get-request: Unable to cache '/api/webApi/ServiceProviderApi_GetAll?cache=100' because it is a 'POST' request and only 'GET' requests can be cached.
workbox: {
runtimeCaching:[
{
urlPattern: ({ url }) => url.pathname.startsWith('/api/webApi') && url.searchParams.has('cache'),
handler: 'CacheFirst',
method: 'POST',
options: {
cacheName: 'api-cache',
plugins: [
{
fetchDidSucceed: async ({request, response}) => {
const cacheTimeParam = new URL(request.url).searchParams.get('cache');
const maxAge = cacheTimeParam ? parseInt(cacheTimeParam, 10) : null;
if(maxAge){
}
return response;
},
},
],
},
}
]
},Metadata
Metadata
Assignees
Labels
DiscussAn open question, where input from the community would be appreciated.An open question, where input from the community would be appreciated.