ServiceWorker' fetch'事件未触发

时间:2017-07-20 14:16:20

标签: service-worker

获取事件:

self.addEventListener('fetch', function(event) {

    console.log("[Service Worker] fetching "+event.request);

    event.respondWith(
        caches.match(event.request)
            .then(function(response) {
                    // Cache hit - return response
                    if (response) {
                        return response;
                    }
                    return fetch(event.request);
                }
            )
    );
});

0 个答案:

没有答案