Back to Content

FetchEvent: isReload property

files/en-us/web/api/fetchevent/isreload/index.md

latest984 B
Original Source

{{APIRef("Service Workers API")}}{{deprecated_header}}{{Non-standard_header}}{{AvailableInWorkers("service")}}

The isReload read-only property of the {{domxref("FetchEvent")}} interface returns true if the event was dispatched by the user attempting to reload the page, and false otherwise. Pressing the refresh button is a reload while clicking a link and pressing the back button is not.

Value

A boolean value.

Examples

js
self.addEventListener("fetch", (event) => {
  event.respondWith(async () => {
    if (event.isReload) {
      // Return something
    } else {
      // Return something else
    }
  })();
});

Browser compatibility

{{Compat}}

See also