I was experimenting with getting images from Firebase Storage as opposed to hosting them as an asset alongside my Angular project. I am hosting the project with Firebase as well.
I found that after an image is cached, it still takes upwards of 400 ms to load an image that was previously retrieved from Firebase Storage. Whereas a cached image that was hosted alongside the website takes around 10 ms.
I was under the impression that cached images were saved locally on the client, so why the huge difference in loading times?
Image is a 240 KB jpeg.
Network request for hosted asset (cached)
Network Request for Firebase Storage (cached)
I've read this question: Firebase Storage very slow compared to Firebase Hosting
But my question is in regards to image caching, so I didn't think the CDN would help anything.
I have solved this issue by making the image public following these instructions: https://cloud.google.com/storage/docs/access-control/making-data-public the cached image now loads in about 15 ms.
I'd still like to know why a cached image would take 400 ms to load, I think there is something I don't understand about caching.