Solved

Using cookies to store chunks of HTML?

Posted on 2014-01-29
3
192 Views
Last Modified: 2014-11-12
I have an intranet database system where the header has a list of the last 5 orders viewed and the last 5 clients viewed.

The database is actually on Azure, while the website had to be moved to an Amazon server.

(Trust me, there were specific reasons we got stuck with this)

So, each page, I have to go to the DB and back to the server for both the information on the page and this stuff, which ONLY changes when the user looks at a job or client.

When everything was on Azure, it was pretty snappy, but now there's a clear lag.  So here's my plan and maybe you folks can improve upon it.

(and I can't use session vars because we have load balancers, etc..)

I was thinking about taking the HTML in the div where I display these sets of links and just dropping it in a cookie.  When the hit a job or a client, I'd just update the cookie.  Then, when generating each page, I'd just use javascript to populate those divs with the cookie values.  (right now I actually pull them via ajax after the page loads.)

It's really only about 1k of data.

Since a cookie gets posted back to the server with every page, there's that extra load between client and webserver, but perhaps that's worth the reduction in traffic between the DB and the webserver and the additional stored proc call on the DB?

What would be really nice would be a way I could just have a cookie that didn't post back, but just some HTML that could be cached on the user's machine.  Maybe HTML5 has that?
0
Comment
Question by:Danielcmorris
  • 2
3 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39819331
I'm not sure about the idea.  You do have to provide for situations where the cookies are not remembered.  Some people frequently clear their cache and cookies and people using 'private' browsing erase cookies when the browser is closed.
0
 
LVL 4

Accepted Solution

by:
Danielcmorris earned 0 total points
ID: 39819344
I think I just found the solution.

HTML5 has localStorage, where it maintains the ability to store data on the user's computer as well as sessionStorage, which maintains the ability to store data that will be cleared out when the browser closes.

I'm going to cache the data in localStorage, rebuilding it on login.

-dan
0
 
LVL 4

Author Closing Comment

by:Danielcmorris
ID: 39829089
.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now