0

I am building an MVC4 application with a heavy emphasis on front-end dynamically generated content. The specific section in question is a page with a grid of variable length taking up about ~50% of the page, and the right half populating a details section related to the user selection on the grid.

Each click will run a few ajax calls off to the server, that run some LINQ queries to the db, and toss back some relevant data which is passed to my ajaxcallback function to create some dynamic HTML, here's some pseudo-code:

onActiveRowChanged => $.ajax({ action: "Home/GridData", success: createGrid }); 

createGrid(obj) {
       dataHTML += "<div class='something'>" + obj[0].ID + "</div>";
       details.append(dataHTML);
}

I've managed to reduce some network traffic through the use of a delay when cycling through grid items too quickly, but I'm afraid it won't be enough. We will have many users on their instances of this application for entire days...many times multiple users per client account. If I fire a query for each grid selection the traffic will get monstrous.

So my question is: can I cache the dataHTML variable in the above example in an elegant way with inherent functionality in MVC/HTML5, should I instead pull html "templates" from external .html files, or should I do something entirely different?

Mike H.
  • 1,731
  • 9
  • 31
  • Look here for a possible answer using the returned xhr object to abort calls. http://stackoverflow.com/questions/4551175/how-to-cancel-abort-jquery-ajax-request – KnowHowSolutions Oct 15 '13 at 20:18
  • @KnowHowSolutions thanks for the response but I'm not concerned about canceling/managing the calls themselves, but whether or not to actually use them and, if so, how to cache the results short of writing a really lengthy storage procedure. – Mike H. Oct 15 '13 at 20:22
  • If it's really static data, then you could just push down an in-memory json object and requery against that locally. I don't believe you can reliably use localdb or localstorage yet. But if it isn't really static data, then you need to make the network call. The json object as data has worked for me on a few pages before. – KnowHowSolutions Oct 15 '13 at 20:25

0 Answers0