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.
本文探讨了在网络连接不稳定的情况下如何优化用户体验。通过采用离线优先的策略,在页面加载时同时从缓存和服务器请求数据,确保即使在弱网环境下也能为用户提供即时的内容展示,从而改善整体体验。
330

被折叠的 条评论
为什么被折叠?



