[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. ...
随机推荐
- Python中%s和%r的区别
早先使用Python工作的时候,对于格式化输出%s和%r的使用都是混着用的. 这一次就出错了: cu.execute("insert into ipPool values(null, '%r ...
- Android 学习手札(备注)
1.在Android 应用程序中不能使用System.out.println(..)来输出信息,而要使用Log类中的静态方法输出调试信息. Log.d("onStart", &qu ...
- visual studio中验证控件的使用
1.RequiredFieldValidator:验证一个必填字段,如果这个字段没填,那么,将不能提交信息. RequiredFieldValidator控件中,主要设置三个属性: (1)ErrorM ...
- PHP常用代码段:
1.PHP加密解密 function encryptDecrypt($key, $string, $decrypt){ if($decrypt){ $decrypted ...
- php报警:Strict Standards: Only variables should be passed by reference in
错误原因 因为end函数的原因. end函数: mixed end ( array &$array ) 你可以看到end的参数是一个引用(reference),而你只能把一个变量的引 ...
- MBR
Mbr位于磁盘的0柱面,0磁头,1扇区. MBR 有三部分构成,主引导程序,硬盘分区表DPT和,硬盘的有效标志55AA.在512个字节的主引导扇区里. 主引导程序占446个字节,dpt占6 ...
- ios中关于delegate(委托)的使用心得
ios中关于delegate(委托)的使用心得 分类: iOS开发2012-05-15 10:54 34793人阅读 评论(9) 收藏 举报 iosuiviewtimerinterfaceprinti ...
- 从一到二:利用mnist训练集生成的caffemodel对mnist测试集与自己手写的数字进行测试
通过从零到一的教程,我们已经得到了通过mnist训练集生成的caffemodel,主要包含下面四个文件: 接下来就可以利用模型进行测试了.关于测试方法按照上篇教程还是选择bat文件,当然python. ...
- Javascript系列之js简介
JavaScript是一种网络客户端脚本语言,javascript有三个组成部分: 1)核心(ECMAScript)---描述了语言的基本语法和对象 2)文档对象模型(DOM)---描述了处理网页内容 ...
- BZOJ 1037 生日聚会
Description 今天是hidadz小朋友的生日,她邀请了许多朋友来参加她的生日party. hidadz带着朋友们来到花园中,打算坐成一排玩游戏.为了游戏不至于无聊,就座的方案应满足如下条件: ...