0

I am trying to add instrumentation code to calculate the total time a client takes to fetch a resource(image, video...) from server.

This is the code:

const response = await fetch(url, {headers});

This response is loaded into a HTMLImageElement using new Iamge() and src is pointed to url of the blob using createObjectURL.

I want to ignore the request time if the image was pulled from cache. I see the message in chrome dev tools next to response status (from disk cache).

is there a way to access it in my code ?

Saaras
  • 379
  • 5
  • 17
  • 1
    this might help https://stackoverflow.com/questions/12830425/how-to-detect-when-xhr-returns-a-cached-resource – Andrew Lohr Jan 24 '19 at 18:36
  • I am performing a cors call and Date is not part of the simple headers. Need to check if that can be added to the backed using `Access-Control-Allow-Headers` – Saaras Jan 24 '19 at 18:44

0 Answers0