Reputation: 9905
I have a website which has a lot of combo boxes
and auto-complete
textboxes
, that take in data from the database masters.
I don't want the data to be loaded each time a user enter logs in, or the page refreshes.
What would be the most efficient and secure and fastest method to load and store data for the client.Also consider a medium sized database.
I tried a few things like,
Javascript
array- Its lost once the user refreshes.Servlets
to load data and fill in on the page, that too has
same problem with refreshing.ajax
and filling when ever required.server side
by loading it once,this saves me
the querying the database everytime. But with every logout/login it
has to be maintained.Is there a method better than this
P.S. Try not to make this too subjective, Please reply only the methods with a brief description of it.
Upvotes: 2
Views: 405
Reputation: 23
HTML5 local storage seems to be a good solution, but if HTML5 is not an option for you i did something similar as you are trying to do in the past by simply serializing options and save it into cookies.
Upvotes: 0
Reputation: 12037
It also depend on your setup that queries and loads the data. ASP.NET has some very good built in caching which can be set so avoiding the whole issue.
Ultimately, in anyone given project I find I use a few different options;
from page caching
(so the server caches the page output),
to using session cookies
to hold certain data which can be carried around the site,
to persistant cookies
if needed,
Certain data suits being carried around by QueryStrings
,
with some suiting an ajax
or json
setup to get the data on demand,
finally some just suiting a vanilla query and load into the page.
With all these at your disposal, it's a case of picking the right tool for the job. A 200 character string isn't suitable to be passed in a QueryString
. If it's only use once on one page, then putting it in a session cookie
could be suitable. If it's going to be updated frequently, then probably an ajax
/ json
call would be better.
An ID
however would lend itself better to being passed in a QueryString
, along with form values (say the index of dropdownlists), etc, etc.
As a final note, it's worth checking how long these queries to the database are taking, as you could be putting in a lot of effort for milliseconds of returns.
Upvotes: 0
Reputation: 2681
HTML5 local storage should work fine for you, however, if you like this to work across older browsers that do not support HTML5 take a look at: http://code.google.com/p/sessionstorage/
I have used it before in different applications and it works great. Also, why not use good old cookies?
Upvotes: 1
Reputation: 5736
You should consider using HTML5 local storage.
Here's a demo!
And a tutorial.
Upvotes: 1