Tim Lieberman
Tim Lieberman

Reputation: 571

How to store ajax return data into the browser cache

I'm returning a lot of configurations to the browser through ajax request. I'm wanting to store the objects into the browser cache. NOT the html5 local storage. I have well over 5mb worth of objects that need to be stored. Is there a way to set this data through the java script and then be able to access it later? I haven't been able to find much if any good material on the subject.

Upvotes: 0

Views: 1314

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114417

One little-known fact is that window.name can hold about 4MB of data. If you stringify your JSON you can stash it in there. Note, that this is not domain-safe, so any other page will have access to that data as well. You can get around this by using an Iframe in your own page, then set the window.name value of the Iframe. So, in theory you could use multiple Iframes to hold different data segments.

See:

http://skysanders.net/subtext/archive/2010/10/11/leveraging-window.name-transport-for-secure-and-efficient-cross-domain-communications.aspx

Cross domain access to iframe using window.name

http://blog.piotrj.org/2009/04/wndowname-hack-taken-step-further-full.html

Upvotes: 1

Related Questions