I am doing a page speed optimization for my website and studying how other websites do it. I noticed that some websites such as as Facebook or Ringgitplus show 0 bytes for some of their resources in Chrome’s developer tools, Network tab, while the real content size is several kilobytes.
I read some articles that says that size is the amount being fetched and content is the actual size of the response. So when size is 0 bytes, it means it served from cache. But the same thing happened when I open the page using Incognito or clearing all my cache.
How is this possible and how can I achieve the same thing for my websites?
5
Understanding Chrome’s behavior is easiest to see in a site that supports both http and https.
If you open Developer Tools and view this image, then Chrome reports 27.1k if the image is cached and 257 bytes if it is not. You can clear your cache inside Developer Tools by right-clicking on the area on the bottom of the screen (for example next to nav_logo161.png).
Now open the link with https. Chrome reports 0 bytes whether the item is cached or not. If it is cached you get a 304, and if it is not cached you see a 200 status. But you can see in the latency that the uncached response takes much longer.
So, long story short, if you want Chrome to report 0 bytes for your web-page use https.
This bug is recorded here and here.
This bug is noticeable primarily when viewing images. The reason you notice it with the http links in the original post is that both sides actually render in https.