4

I'm trying to measure page load performance of real website users. To make better sense of the data, I'd like to segment the data by whether or not the cache was primed.

So I don't need to know before loading a resource if it was in the cache. It's enough to measure after the fact.

At least in Chrome and Firefox, the dev tools "network" tab has a column which displays the transferred size. Is it possible to get this info with JavaScript?

The Resource Timing API appears to have a provision for exactly this case ("transferSize must return 0 if resource retrieved locally"), but no browser has implemented it yet.

The fact that the dev tools display this information makes me wonder if it's accessible somehow. Any ideas?

Chris
  • 44,602
  • 16
  • 137
  • 156
Brian
  • 331
  • 1
  • 6
  • 19
  • Just because something is available in the DevTools of a particular browser, this doesn't mean that this information is available through JavaScript. However, in the case of the Resource Timing API, it does appear that this is fully supported on [almost all modern browsers](http://caniuse.com/#feat=resource-timing). Therefore you should be able to retrieve this information. If you are having an issue using this API, please post a minimal (not-)working sample and we can try and help you address a specific issue. Otherwise this question may get closed. – Chris Jan 25 '16 at 15:47
  • The ResourceTiming API is working fine. I can get a PerformanceResourceTiming instance for any resource I've loaded. But the property "transferSize" is not defined. This is reflected in the MDN Article I linked, where all browsers are listed as "Not Supported" – Brian Jan 25 '16 at 15:55
  • 1
    OK, then it looks like caniuse could be updated to reflect this. Just for reference, here appear to be two relevant bugs for [Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1154309#c49) and [Chromium](https://code.google.com/p/chromium/issues/detail?id=467945). – Chris Jan 25 '16 at 16:14
  • Thanks for the Bugtracker links, that's useful. The Firefox one appears to be fixed and scheduled for release with Firefox 45. I tested it with the Firefox Dev Edition, and it works as advertised. I'll just hold on the data segmentation until this feature is available and widespread. If you want to post those links in an answer, I'll mark it as the accepted answer. – Brian Jan 25 '16 at 16:31

1 Answers1

4

It appears that whilst the Resource Timing API is supported in most modern browsers, recent changes to the Resource Timing API specification, such as the transferSize property, have not yet been implemented.

Here are the relevant bugs reporting this for Firefox and for Chromium.

As mentioned in the comments to the question, it appears that this has been addressed in Firefox and will be released in Firefox 45. I have confirmed that transferSize is currently available in the Firefox Developer Edition (v45.0a2).

Chris
  • 44,602
  • 16
  • 137
  • 156