Coder Social home page Coder Social logo

Comments (4)

jkpang avatar jkpang commented on May 26, 2024

如果缓存的接口数据在服务器端有更新呢,如果不重新请求,岂不是一直都加载缓存的旧数据了?
PPNetworkHelper的缓存策略是,不管有无网络,都:

1.先加载上次缓存在本地的数据 ->展示
2.然后再请求服务器的数据 ->展示
3.最后再缓存本次的服务器数据 ->等待下次展示

所以当用户即使在没网络的情况下请求服务器数据失败,仍然可以加载上次缓存的数据,不会导致APP的界面一片空白,这样会极大的提升用户体验. 在某些情况下可以缓存一些常用且不会经常变动的数据,避免每次用到都要请求服务器,以减轻服务器的压力.
@songxing10000

from ppnetworkhelper.

songxing10000 avatar songxing10000 commented on May 26, 2024

如果缓存的接口数据在服务器端有更新呢,如果不重新请求,岂不是一直都加载缓存的旧数据了?
之前我也是这样想的,可是后台,在请求接口时,没有返回304给我,每次都是200。所以对于 缓存的处理比较头痛,

from ppnetworkhelper.

jkpang avatar jkpang commented on May 26, 2024

那你用PPNetworkHelper就可以满足你的要求了,如果你非得要根据服务器给你返回的状态码来判断是否进行缓存,,那就要自己和后端工程师商量了,让他给你一个准确的状态码.

from ppnetworkhelper.

songxing10000 avatar songxing10000 commented on May 26, 2024

不错,明白了,感谢

from ppnetworkhelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.