How to cache AJAX content after mouse

I have a main menu like this:

CARS MOTORCYCLES TRUCKS BUSES 

Each of these elements has its own submenu containing a list of creators for a specific element. This list can be about 40 items, and I would like to call if after mouseover / click on the main menu item. This part is ok, no problem with that.

I would like to know how I can cache pages / parts containing a list of creators. I would like to call and load a submenu only for the first time, while others just call it from the cache to prevent unnecessary data transfer.

thanks

+4
source share
2 answers

The Ajax API provides default caching to enable this, add the cache parameter set to true . For instance:

 $.ajax({cache:true, url:'http://xyx.com', success: function(res){}}); 

Refer to the jQuery Ajax API .

+2
source

Are the appropriate caching headers of the AJAX response appropriate for the server, for example. via Expires: or Cache-Control :?

0
source

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


All Articles