The following links trigger responses generated by the
service worker. There are two
fetch
handlers
registered in the service worker: the one that's registered first intercepts requests ending
with
/hello/world
and the one that's registered second intercepts requests that
contain
/hello/
anywhere in their URL.
Since it's registered first, the handler which intercepts
/hello/world
requests
will always have the first chance to return a response via
event.respondWith().
Only if the first handler doesn't call
event.respondWith(), the second handler
gets its chance to call
event.respondWith().
If none of the registered
fetch
handlers call
event.respondWith(),
then the browser will handle the request by making a normal HTTP request, as if there were
no service worker involvement. This isn't an error condition, and it's a fine way
of ensuring that the default behavior is triggered.