FetchEvent()
The FetchEvent() constructor creates a new FetchEvent object.
Syntax
var fetchEvent = new FetchEvent(type, init);
Parameters
type-
A
DOMStringobject specifying which event the object represents. This is alwaysfetchfor Fetch events. -
initOptional -
An object conforming to the
FetchEventInitdictionary, containing options to apply to the event object. Options are as follows:-
clientIdRead only -
The
Clientthat the current service worker is controlling. -
isReloadRead only -
A boolean value that signifies whether the page was reloaded or not when the event was dispatched.
trueif yes, andfalseif not. Typically, pressing the refresh button in a browser is a reload, while clicking a link and pressing the back button is not. If not present, it defaults tofalse. -
preloadResponseRead only -
A
Promisewhich returns a previously-loaded response to the client. -
replacesClientIdRead only -
A
DOMStringwhich identifies the client which is being replaced byresultingClientId. -
resultingClientIdRead only -
A
DOMStringcontaining the newclientIdif the client changes as a result of the page load. -
requestRead only -
The
Requestobject that would have triggered the event handler.
-
Specifications
| Specification |
|---|
| Service Workers 1 # dom-fetchevent-fetchevent |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
FetchEvent |
40 |
17 |
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
|
No |
27 |
11.1 |
40 |
40 |
44 |
27 |
11.3 |
4.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/FetchEvent