Caching Design for Medium / Small Web Application?

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?

+3
source share
2 answers

Sounds good to me. You basically create your own caching system. You have a way to invalidate and update your cache on demand. That every caching system has a core.

Regarding the available libraries for jQuery, I cannot say.

+1
source

jCache - jQuery, (URL ). , ( Date ).

0

Source: https://habr.com/ru/post/1753022/


All Articles