I have a json file that I need to store for each user.
Storing as a cookie
The json is 3kb so it's less than the 4kb limit the cookies have
Storing as a file on
my server /json/user13.json
Storing in the database
(user_id (int, primary key), json (blob)
This will be retrieved quite often
The json file will be initially generated from the database and
I'm thinking of storing it as a cookie or file as a way to help
the server perform slightly faster.
Thank you!
Will not let me put a simple comment so I extend a bit for fun, have you thought about using html5 localStorage?
Write:
var obj = {foo: 'bar'};
localStorage.setItem('obj', JSON.stringify(obj)); //<-- saved as JSON string
(saved as string because you can not save json objects in localStorage, soo, strings, and you has a 5 mb limit i think)
Read later:
var obj = JSON.parse(localStorage.getItem('obj'));
I do not know if it's an option for you in this case
Edit:
For other browsers without localStorage can use https://github.com/wojodesign/local-storage-js
Basically when not have localStorage use or Global Storage: - https://developer.mozilla.org/en/dom/storage#globalStorage
Or userData: - http://msdn.microsoft.com/en-us/library/ms531424(v=vs.85).aspx
I do not know how much support 'back' is achieved, but allows browsers such as IE5, 6 and 7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With