如何在接收firefox推送通知时删除缓存
我的service-worker.js中有以下代码行用于处理chrome和mozilla上的传入推送通知:如何在接收firefox推送通知时删除缓存,firefox,push-notification,google-cloud-messaging,mozilla,service-worker,Firefox,Push Notification,Google Cloud Messaging,Mozilla,Service Worker,我的service-worker.js中有以下代码行用于处理chrome和mozilla上的传入推送通知: var httpHeaders = new Headers(); httpHeaders.append('pragma', 'no-cache'); httpHeaders.append('cache-control', 'no-cache'); var fetchInit = { method: 'GET', headers: httpHeaders, };
var httpHeaders = new Headers();
httpHeaders.append('pragma', 'no-cache');
httpHeaders.append('cache-control', 'no-cache');
var fetchInit = {
method: 'GET',
headers: httpHeaders,
};
// Version 0.1
console.log('Started', self);
self.addEventListener('install', function(event) {
self.skipWaiting();
console.log('Installed', event);
});
self.addEventListener('activate', function(event) {
console.log('Activated', event);
});
var urlToRedirect='';
self.addEventListener('push', function(event) {
console.log('Push message', event);
//var title = 'Push message2';
event.waitUntil(
fetch("http://abc/xyz/latest.json", fetchInit).then(function(res) {
res.json().then(function(data) {
// Show notification
urlToRedirect = data.data.url;
self.registration.showNotification(data.data.title, {
body: data.data.body,
tag: data.data.tag,
icon: 'images/icon.png'
});
});
}));
//}));
})
当我在latest.json中更改某些内容并发送推送通知时,它仍然从旧的json文件加载数据。如何确保它从更新的json中获取数据。为此,我使用了pragma和cache控件头,它在chrome中运行良好,但在firefox中不起作用。如何在firefox中工作。您可以使用
缓存
参数进行调用
例如,通过将其设置为无存储
,可以完全绕过缓存
有关更多详细信息,请阅读中的缓存模式的说明