I have been analyzing the cache storage use of complex application, when I realized that the stored image or script with certain content-length N
actually takes 5N-10N
space in the cache storage.
Consider this sample: I am requesting image from OpenStreetMap via service worker and storing it in cache. There is only one image stored in cache. The Chrome version is the latest one (Version 65.0.3325.146 (Official Build) (64-bit)).
This is the view of cache storage after refresh:
This is the view of clear cache tab:
So, the problem is that the image which has the size of 6.4KB
actually takes 13.8MB
of cache storage. Am I missing something?
The live example can be seen at https://googlechrome.github.io/samples/service-worker/basic/ - less than 10KB
of scripts occupy almost 50KB
of cache storage.
So, the question is: how comes that when files are cached via service workers the space that they occupy significantly increases? I agree that the actual request weights more that actual response, but not 10 times more.
Links that might be useful:
- Chrome dev tools showing high cache storage utilisation
- Service Worker issues
- https://bugs.chromium.org/p/chromium/issues/detail?id=795134