[PWA] 5. Hijacking one type of request
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的更多相关文章
- [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 ...
- [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 ...
- Spring boot 项目中put提交Date数据时出现type=Bad Request, status=400状态码
1.问题原因 经过测试发现,当客户端页面提交日期为空时会出现以下异常,如果提交日期不为空则不会出现上述问题.出现这种错误的原因是没有对代码中的Date型参数进行格式化,接收为null的日期类型参数时, ...
- Helpers\Request
Helpers\Request The Helpers\Request class is used for detecting the type of request and retrieving t ...
- HTTP SOAP Request
public string SoapRequest(string url, string message, string type, Encoding encoding) { string resul ...
- Visual Studio Code 通过 Chrome插件Type Script断点调试Angular 2
1. 下载Visual Studio Code (https://code.visualstudio.com/) 2. 安装插件Debugger for chrome 3. 确定tsconfig.js ...
- request.get_full_path() 和request.path区别
1. 都是获取request 请求的url路径 2. request.get_full_path() -- 获取当前url,(包含参数) 请求一个http://127.0.0.1:8000/200/? ...
- .net core web api 获取request body的纯文本
本文代码 https://github.com/wuhaibo/readPlainTextDotNetCoreWepApi 总有些时候我们希望获得Request body 的纯文本 那么怎么做呢?很简 ...
- 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. ...
随机推荐
- nginx插件ngx_lua
ngx_lua是淘宝的维护的产品,真心不错.配置文件包含可以做很多事情的lua脚本. 公司有个产品对注册的广告盒子进行反向代理,这样可以在盒子上做很多事情:和服务器通信,远程控制盒子等等.nginx反 ...
- 1. mybatis批量插入数据
通过list <insert id="saveByList" useGeneratedKeys="true" parameterType="ja ...
- Java 可变参数
java1.5增加了新特性:可变参数:适用于参数个数不确定,类型确定的情况,java把可变参数当做数组处理.注意:可变参数必须位于最后一项.当可变参数个数多余一个时,必将有一个不是最后一项,所以只支持 ...
- Canvas中点到点的路径运动
/*随机生成两个点,然后以两点为端点,进行运动,主要使用了SetInterval,对画布进行不断的擦除描绘的操作*/1 <!DOCTYPE html> <html xmlns=&qu ...
- One-day-学习笔记-商品成交时发送短信
个人学习笔记(one) 根据需求:商品成交时发送短信 html代码省略..... Model代码省略..... /* * --------------------------------------- ...
- windows 下PHP 和 nginx配置
http://www.cnblogs.com/huayangmeng/archive/2011/06/15/2081337.html
- Python,遍历目录下TXT
import os #获取根目录,递归得到所以txt文件的路径 list_dirs = os.walk(os.curdir) txtfilenames=[] for root, dirs, files ...
- C语言陷阱——类型转换
以下例子取自<深入理解计算机系统>. 考虑如下的C语言代码: #include<stdio.h> typedef unsigned char* byte_pointer; vo ...
- ios的Ping++支付接入步骤-b
1. Client 发送支付要素给 Server 2. Server 发送支付请求并将返回的支付凭据传给 Client 3. Client 调起支付控件完成支付 4. 渠道同步返回支付结果给 Clie ...
- awk里的各种坑
今天又遇到一个,一旦需要定义一个局部数组(awk通过把局部变量定义在函数参数列表来实现局部这一特征)那么这个数组可以正常的操作,但是无法对他取长度,一旦使用length(tempArr)会得到这么一个 ...