"serviceworker.js" is fetched several times in a row
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jul 2018 01:57:36 +0000 (01:57 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jul 2018 01:57:36 +0000 (01:57 +0000)
commitf188dacb825dbd45041079c450fea61940c6b780
tree2b36eeb52ef6315bcdd7176673aa6e759e3eb843
parent5c436b3c4efe8ecdd6ad48618fecc9c9b8dbfafb
"serviceworker.js" is fetched several times in a row
https://bugs.webkit.org/show_bug.cgi?id=187435
<rdar://problem/41940569>

Reviewed by Youenn Fablet.

Soft updates happen every time a fetch event is sent to a service worker for a main resource request.
This can happen many times during a page load and will cause us to spam the HTTP server with update
requests, especially considering that the default behavior is to bypass the HTTP cache. To address
the issue, we now do soft updates on a 1 second delay and we keep rescheduling this timer was long as
soft update requests keep coming. Based on my understanding of the Chromium code, this seems to be
what they are doing so this should align our behavior with them.

* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
(WebCore::ServiceWorkerRegistration::scheduleSoftUpdate):
* workers/service/ServiceWorkerRegistration.h:
* workers/service/context/ServiceWorkerFetch.cpp:
(WebCore::ServiceWorkerFetch::dispatchFetchEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
Source/WebCore/workers/service/ServiceWorkerRegistration.h
Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp