标签:
Previously we saw how to Hijacking all the reqest, but this is not useful. So now we want to see how to Hijacking one kind of request. For example we want servce worker only response to the request ends with ".jpg":
self.addEventListener(‘fetch‘, function(event) { // TODO: only respond to requests with a // url ending in ".jpg" if(event.request.url.endsWith(".jpg")){ event.respondWith( fetch(‘/imgs/dr-evil.gif‘) ); } });
https://developer.mozilla.org/en-US/docs/Web/API/Request
[PWA] 5. Hijacking one type of request
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5496820.html