Not sure how to make use of cache?
- if (!sessionStorage.getItem('GotTags')) {
- $.ajax({
- url: "Search/GetTags",
- method: "GET",
- datatype: "json",
- success: function (data) {
- sessionStorage.setItem("tags", JSON.stringify(data.songTags.concat(data.albumTags, data.artistTags)));
- sessionStorage.setItem('GotTags', 'true');
- }
- });
- }
-
- $("#searchString").autocomplete({
- source: function (request, response) {
- var tags = JSON.parse(sessionStorage.getItem("tags"));
- var results = $.ui.autocomplete.filter(tags, request.term);
-
- response(results.slice(0, 10));
- },
- minLength: 3
- });
-
Okay so the code above gets the tags and stores them in session variable, I only do this once so that it doesn't go through each time the page is refreshed.
My question is can I make use of the Ajax cache to store this information and only go through the function if it isn't cached or is my way fine?
I am not sure how cache works properly yet, how can I access cached variables?