[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反 ...
- php学习小技巧
1.print_r可打印数组 <?php echo '<p class="ajax">This paragraph was loaded with AJAX.&l ...
- python3 读写excel
一直认为python3可以很快的实现很多简单的功能,今天要读excel表格数据,想来很简单,网上一搜,用xlrd即可,然后很多人给出了不同的版本,号称xlrd3,实际上官网一看,xlrd0.9.4兼容 ...
- call/apply的第一个参数如果为null。this指向window
call/apply是用来改变函数的作用域的,第一次参数为this,第二个参数为传输的值,例如 var a ="windowA"; var b = "windowB&qu ...
- DOM对象控制HTML无素——详解2
节点属性 在文档对象模型 (DOM) 中,每个节点都是一个对象.DOM 节点有三个重要的属性 : 1. nodeName : 节点的名称 2. nodeValue :节点的值 3. nodeType ...
- webapp开发——‘手机屏幕分辨率’与‘浏览器分辨率’不要混淆
关于webApp响应式设计遇到的问题,分享给大家,最近在做一个手机webApp,因为我手机是”米3“,屏幕截图大小是1080宽,所以css样式用@media screen and(min-width: ...
- Linux学习2
第三讲Linux常用命令04 压缩:gzip: 1.只能压缩文件,不能压缩目录 2.不保留源文件 解压缩:gunzip gzip -d ------------------------------ ...
- 完美世界-2015校园招聘-java服务器工程师-成都站
给定一个整数,将该整数分解成多个2的幂次方相加的形式,每次都取最大的可以分解出来的2的幂次方 比如 65 64 1 1 1 2 2 package wanmanshijie; import java. ...
- 使用CSS3改变选中元素背景色
CSS3代码如下: /* SELECTION ----------------- */ ::-moz-selection { background: #f00533; color: white; te ...
- Extjs打开window窗口自动加载html网页
Window inherits the autoLoad config option from Panel. Note that I included all config options below ...