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. 24种设计模式--代理模式【Proxy Pattern】

    什么是代理模式呢?我很忙,忙的没空理你,那你要找我呢就先找我的代理人吧,那代理人总要知道被代理人能做哪些事情不能做哪些事情吧,那就是两个人具备同一个接口,代理人虽然不能干活,但是被代理的人能干活呀. ...

  2. ICE学习第三步-----Slice语言

    ICE:Slice语言(一)-编译 Introduce简介 Slice(Specification language for ice)是分离对象和对象的实现的基础的抽象机制.Slice在客户端和服务器 ...

  3. WAMP学习日记之:Apache发布php网站

    1.修改httpd.conf 文件,以便让Apache和php模块建立关联 2.配置php.ini文件 修改httpd.conf 文件,以便让Apache和php模块建立关联 如何让apache和ph ...

  4. pkg-config相关的常用指令

    pkg-config用途: 查询系统已安装库的基础信息(元信息) 1.查看所有的pkg-config库 pkg-config --list-all --list-all  列出pkg-config路径 ...

  5. apt-cache madison package-name

    apt-cache madison package-name 搜索软件有那些可用版本,

  6. 如何编写一个简单的makefile

    一个规则的构成 目标:依赖1,依赖2······ 命令 例子: objs := init.o nand.o head.o main.o nand.bin : $(objs) arm-linux-ld ...

  7. Phalcon的学习篇-phalcon和devtools的安装和设置

    A Phalcon在Windows上的安装 1 从Phalcon for Windows下载适合的DLL, 这里的适合 主要看两个方面 1 PHP的版本 2 线程是否是安全 3 编译版本 如果不清楚这 ...

  8. Javascript学习之函数(function)

    在JS中,Function(函数)类型实际上是对象;每个函数都是Function类型的实例,而且都与其他引用类型一样具有属性和方法.由于函数是对象,因此函数名实际上也是一个指向函数对象的指针. 一 函 ...

  9. VS快捷键和技巧

    1. 怎样调整代码排版的格式? 选择:编辑->高级->设置文档的格式或编辑->高级->设置选中代码的格式. 格式化cs代码:Ctrl+k+f 格式化aspx代码:Ctrl+k+ ...

  10. Ugly Windows

    poj3923:http://poj.org/problem?id=3923 题意:给出两个整数n.m表示屏幕的长宽.屏幕上有一些窗口,每个窗口都是矩形的,窗口的边框用同一个大写字母来表示,不同的窗口 ...