[PWA] 0. Introduce to Offline First
2016-05-15 16:35
274 查看
Why offline first?
Imagin you are visiting a website, it is fine if wifi connection is good. It might be also "fine" if show you "Your don't have internet connection", so you give up. The worse case is you have really poor wifi connection and the page is trying to loading, but nothing comes up. So you just wait and wait...
Noramlly online first soultion is trying to connect network (server) first. If cannot connect then fetch data from cache. This is not so good, because you still need to wait and wait util network fallback then you will get cache data. How about we do:
When page loading, send two request.
One request going to cache to fetch as much as we can to display on the screen.
Another reqest going to the reall server, get data update.
If we are in really poor wifi connection, at least we get something, we see something, better than nothing.
If the connection is good, the cache data will be replaced with real data and interface update immediately. This will provide a better user experence.
Imagin you are visiting a website, it is fine if wifi connection is good. It might be also "fine" if show you "Your don't have internet connection", so you give up. The worse case is you have really poor wifi connection and the page is trying to loading, but nothing comes up. So you just wait and wait...
Noramlly online first soultion is trying to connect network (server) first. If cannot connect then fetch data from cache. This is not so good, because you still need to wait and wait util network fallback then you will get cache data. How about we do:
When page loading, send two request.
One request going to cache to fetch as much as we can to display on the screen.
Another reqest going to the reall server, get data update.
If we are in really poor wifi connection, at least we get something, we see something, better than nothing.
If the connection is good, the cache data will be replaced with real data and interface update immediately. This will provide a better user experence.
相关文章推荐
- Spring_Spring_教程8_注入_复杂类型的注入
- Shell脚本输出斐波拉契数列前十项,每行显示两个数
- keepalived ,egnix ,tomcat 高可用,高并发 应用架构的搭建
- java多线程之死锁
- 一个极为优雅的椭圆命题(待更新)
- 关于返回JSON.toJSONString的用法
- 【Tyvj】P1003 越野跑【某下午刷水题系列】
- window.onload绑定多个事件的两种解决方案
- Windows下caps键位和右ctrl键位互换方法(注册表)
- 为什么MyISAM是表锁
- ComboBox的联动
- Win8仿Win10无边框效果的实现
- HTTP POST GET 本质区别详解
- mysql连接报错
- 在mac上编译安装Protocol Buffer (C++)
- android 视频的缩略图 缓存机制和 异步加载缩略图
- 动态规划算法之:最长公共子序列 & 最长公共子串(LCS)
- Linux下test命令使用
- C++ HASH_MAP初探
- oracle 数据库查询-关联查询-2