jeudi 19 septembre 2019

How to cache an JSON Response in the browser Session such that on filter or reload, the page does not take a long time

    $("#generateTable").click(function () {
        $.ajax({
            url: "Some JSON web Service URL",
            type: "get",
            cache: true,
            headers: { 'Content-Type': 'application/json' },
            success: function (data) {
                //drawTable(data);
                console.log(data);
                var count = Object.keys(data).length;
                console.log(count);
            }
        });
    });

This is where I am confused. I am making a request to the URL which holds a huge data set with about 40,000 lines of stuff. How can I cache this such that when I am making a filter or reload go through the user does not have to wait for long (currently needs 25 seconds, which is definitely bad UI/UX) . I have been trying LocalStorage, sessionStorage etc., but none of them seem to work. More over, I tried caching the response into an object again and tried addressing but it does not seem to work either. Any help is appreciated. Thanks! Also the AJAX request starts when the user clicks a button "Generate Table" with the ID "#generateTable".




Aucun commentaire:

Enregistrer un commentaire