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的更多相关文章

  1. [PWA] 4. Hijacking Request

    We want to do offline first, the first thing we need to do is we should able to catch the browser re ...

  2. [PWA] 6. Hijacking response

    For example, if the url is not match to any API endpoint, we want to return 404 error message. So fi ...

  3. Spring boot 项目中put提交Date数据时出现type=Bad Request, status=400状态码

    1.问题原因 经过测试发现,当客户端页面提交日期为空时会出现以下异常,如果提交日期不为空则不会出现上述问题.出现这种错误的原因是没有对代码中的Date型参数进行格式化,接收为null的日期类型参数时, ...

  4. Helpers\Request

    Helpers\Request The Helpers\Request class is used for detecting the type of request and retrieving t ...

  5. HTTP SOAP Request

    public string SoapRequest(string url, string message, string type, Encoding encoding) { string resul ...

  6. Visual Studio Code 通过 Chrome插件Type Script断点调试Angular 2

    1. 下载Visual Studio Code (https://code.visualstudio.com/) 2. 安装插件Debugger for chrome 3. 确定tsconfig.js ...

  7. request.get_full_path() 和request.path区别

    1. 都是获取request 请求的url路径 2. request.get_full_path() -- 获取当前url,(包含参数) 请求一个http://127.0.0.1:8000/200/? ...

  8. .net core web api 获取request body的纯文本

    本文代码 https://github.com/wuhaibo/readPlainTextDotNetCoreWepApi 总有些时候我们希望获得Request body 的纯文本 那么怎么做呢?很简 ...

  9. When an HTTP server receives a request for a CGI script

    cgicc: Overview of the Common Gateway Interface https://www.gnu.org/software/cgicc/doc/cgi_overview. ...

随机推荐

  1. OC 字符和日期的互转

    需要用到NSDateFormatter这个类. 1.字符串转换为日期 [plain]NSDateFormatter* dateFormat = [[NSDateFormatter alloc] ini ...

  2. InvalidArgument=Value of '1' is not valid for 'index'

    用ListView实现点击ListView的项删除该项的效果,调用ItemSelectionChanged事件. 代码如下: private void listView1_ItemSelectionC ...

  3. Javascript跳转手机站代码

    $(document).ready(function(){ var mobileAgent = new Array("iphone", "ipod", &quo ...

  4. DbUtils组件

    DbUtils组件 DbUtils组件, 1. 简化jdbc操作 2. 下载组件,引入jar文件 : commons-dbutils-1.6.jar |-- DbUtils 关闭资源.加载驱动 |-- ...

  5. Intrusion Detection of Specific Area Based on Video

  6. bzoj2260: 商店购物 && 4349: 最小树形图

    Description Grant是一个个体户老板,他经营的小店因为其丰富的优惠方案深受附近居民的青睐,生意红火.小店的优惠方案十分简单有趣.Grant规定:在一次消费过程中,如果您在本店购买了精制油 ...

  7. java-web-j2e学习建议路线

      JAVA学习之路(2)  首先要明白Java体系设计到得三个方面:J2SE,J2EE,J2ME(KJAVA).J2SE,Java 2 Platform Standard Edition,我们经常说 ...

  8. Ruby自学笔记(六)— 循环

    循环结构在编程语言中是不可或缺的,所以Ruby中的循环也有其自定义的规则. 而我们关注循环结构,要知道两个因素:1) 循环的条件:2) 循环执行的内容 Ruby有一些方式来实现循环结构体: 1. ti ...

  9. ThinkPHP 3.2 模板使用函数

    {$name|md5|strtoupper|substr=0,3} 编译后的结果是: <?php echo (substr(strtoupper(md5($name)),0,3));?> ...

  10. 在SystemOut.log中发现HMGR0152W: 检测到CPU 饥饿的消息 <转载>

    今天系统报警了!!!!!顿时人又不好了!!!查看系统日志, 报错如下: Did not receive adequate CPU time slice. Last known CPU usage ti ...