I have a web application that currently has ~ 700 LOC in JS (more is serveride). I am using jQuery. As I try to minimize AJAX requests to the server, I have an inconvenient combination of caching design and spaghetti. It seems like I need a more centralized solution.
My idea: Create a map with an AJAX call to do (URL and args), and a dirty bit. If part of the application decides that the data on the card is out of date, it sets the dirty bit to true. If part of the application requests data and the data is dirty or does not exist, the card will request it from the server before returning it. Otherwise, the card will return it directly.
Does this sound like a good design? Or is there a jQuery plugin or some other code that already does this?
source
share