来自Safari 11的serviceWorker.js请求充斥着服务器

时间:2018-04-11 11:37:53

标签: javascript safari service-worker

为什么这会在5秒内连续发生80次:

my.domain.com:443 x.x.x.x - - [11/Apr/2018:06:08:18 +0200] "GET /serviceWorker.js HTTP/2.0" 304 0 "https://my.domain.com/serviceWorker.js" "Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1"

my.domain.com:443 x.x.x.x - - [11/Apr/2018:06:08:18 +0200]
"GET /serviceWorker.js HTTP/2.0" 304 0 "https://my.domain.com/serviceWorker.js"
"Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15
(KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1"

serviceWorker.js的内容:

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

注册serviceWorker的代码:

serviceWorker() {
    if ('serviceWorker' in navigator) {
        window.addEventListener('load', function() {
            navigator.serviceWorker.register('/serviceWorker.js').catch(() => {});
        });
    }
}

0 个答案:

没有答案