首页 > 其他 > 详细

[PWA] 5. Hijacking one type of request

时间:2016-05-16 07:03:15      阅读:275      评论:0      收藏:0      [点我收藏+]

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!