Kevin,
Good night.
Actually when you make an ajax request, using $ .ajax, $ .post, $ .get, the requests will always be an XHR, but the response content can be a datatype: jpeg, gif, png , text / html, etc.
Developer Tools, shows the type of request he is making when triggered through the src of a Image
, he understands that you are loading an image.
When you make the request through a XHR
object ( XMLHttpRequest
), it understands that it is a AJAX
, so it appears in the XHR tab.
In practice:
//Vai em network -> Images
var img = new Image();
img.src = "http://images.forbes.com/media/lists/companies/google_416x416.jpg";
//Vai aparecer em network -> XHR
$.ajax({
type: "GET",
url: "http://images.forbes.com/media/lists/companies/google_416x416.jpg",
dataType: "image/jpg",
cache: true
});
Answer 2:
To put an image in the cache, the best alternative is to use Expires Header
, if you are using Apache, you can look at this link:
link