1

I am using browser cache to store my response data, but wanted to know how feasible it is to store the data in browser cache. Can anyone explain the following:

1. Is their a guarantee that the data will be cached for specific time, if I am storing only JSON data(can be huge).

2. What is the maximum size limit of browser cache.

3. Is my data cross domain accessible?If yes is their a way I can protect it?

4.Does the result vary from browser to browser?
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29

1 Answers1

0

There are two main storage method in modern browsers, localStorage and sessionStorage, in your case I assume you are using localStorage.

For localStorage:

  • the data stored will be persistent as long as the user not clearing the data or you remove them using localStorage.removeItem()
  • the maximum size of localStorage varies from browsers, basically there is at least 2.5MB. details in this post
  • localStorage works just like cookies, so you don't want to store any sensitive stuff, SSL between clicent and server is recommended
  • IE 8 and above, Chrome 4, Firefox 3.5, Opera 10.5 and Safari 4 have already implemented this API

Details about localStorage in this link

Community
  • 1
  • 1
jasonslyvia
  • 2,529
  • 1
  • 24
  • 33
  • @Jacksonville I am setting the header as response.addHeader("Cache-Control", "max-age=" + 20); from my java server so is it going to use local storage in this case? – Phalguni Mukherjee Sep 12 '13 at 08:02
  • No, you're talking about setting cache in server side, I'm talking doing so in client side. I'm not familiar with server side settings, but the answer above is a alternative for you I guess. – jasonslyvia Sep 12 '13 at 08:33