Read complete story

Android: Dealing with server cache

Caching is done on server side to enhance the speed of the server as active data is stored in caches, a relatively smaller and faster memory, and made available to customer whenever request hits. The validity of the data is based upon its expiration time. But sometimes this cache on server ends up giving you stale response for your android Application which in any case is wrong. So how can we control this behavior? We can do this using Http header for controlling cache i.e. Cache-Control.

 

Cache-Control

The Http header Cache-Control give us everything we need, we just have to use it efficiently based on the issues we are getting.

We can set many values to the Cache-Control header. There are many variants of this header such as

public: It lets server know that the response is not specific to any single user.

private: Opposite of public. It sets the response is specific to a single customer e.g. single browser.

max-age=[seconds]: It sets the maximum time upto which the response is treated as fresh. A 0 as seconds means that the response just expires right away.

no-cache: It tells server to do not cache the current request.

and many more.

You can set multiple of then in one go as

or

Just use according to you situation and you will definitely get results.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close