Using last versions of jQuery 1 or 2, I have this simple code that makes a request and shows the result :
var url1 = "cache/1";
var callback1 = function(data, statusText, response){
$("#result1").html("status :"+response.status);
$("#result1").append("<p>"+JSON.stringify(data)+"</p>");
};
$(function() {
$("#query1").on ("click", function(){
$.ajax({
url: url1,
cache: true,
dataType: 'json',
ifModified: true,
success:callback1
});
});
});
On the first request, I read my Json data. On the second request, I have a 304 response as expected, and data is undefined.
How can I show data from the browser cache ?
dataas you did the first time around. Check in the Net tab of your developer tools to make sure the request you are making actually is an if-modified-since one.