Menu

The app shows yesterday's data and nobody wrote any cache code. HTTP caching on mobile, from the response headers up.
📰

The app shows yesterday's data and nobody wrote any cache code. HTTP caching on mobile, from the response headers up.

DEV Community: mobile·MinPin Proxy·14 days ago
#zCNEebh0
#devtomobile#devto#dev#cache#response
Long article (698 words) — no AI summary yet.
Reading 0:00
15s threshold

The bug: a user changes something on the web, opens the app, and sees the old value. Pull to refresh doesn't help. Ten minutes later, or after reinstalling, it's fine. Nobody on the team wrote a cache, so everyone looks for a bug in the backend first.

Often there is a cache, and it's the HTTP cache built into the networking library. It follows the response headers your server sends, including the headers it doesn't send.

Who caches by default

iOS, URLSession : URLSession.shared and the default configuration use URLCache.shared , with the cache policy .useProtocolCachePolicy . So every app has an HTTP cache, in memory and on disk, unless someone turns it off.

Android, OkHttp : no cache until you add one with Cache(directory, maxSize) on the OkHttpClient.Builder .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.