Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

jquery - Using window.name as a local data cache in web browsers

I was reading about cookies and other related client-side storage options, and read about using window.name as a data cache of sorts:

http://en.wikipedia.org/wiki/HTTP_cookie#window.name

While it certainly has things that make it less desirable - and I won't sugar coat it, it is definitely a hack in the most true sense of that word - it looks promising. I have a need to store about 10K of JSON as a client cache, right now I am sending it down with the page and when I read about this it seems like it might actually fit my needs and reduce traffic.

I am curious to see if anyone has implemented this, and what advice you could possibly give. Pitfalls? Recommendations? Differences between browsers? Some sort of usage case that would be really bad?

Pros

  • Local storage
  • Available in basically every browser that supports javascript

Cons

  • Only supports strings
  • XSS Issues
  • window.name poisoning
  • Information leaking to other sites

Alternatives

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are many ways to store local data, Flash LSO, HTML 5 Local Storage, cookies. Google gears. Have a look at PersistJS, a js client library that will just do it.

This post in Ajaxian elaborates a little more about it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...