3 ms·
Many large files that get downloaded are already compressed, so using compression during http response is pointless and just adds overhead. If you need progres
by leptons 2y ago
Many large files that get downloaded are already compressed, so using compression during http response is pointless and just adds overhead.
If you need progress on a text file, then don't compress it while downloading. Text files that are small won't really need progress or compression.
If you're sending a large amount of data that can be compressed, then zip it before sending it, download-with-progress (without http compression), and then unzip the file in the browser and do what you need with the contents.
I'm sure there are probably other ways to handle it too.
- meindnoch 2y ago>I'm sure there are probably other ways to handle it too. Yes, there is. The simplest solution is called XmlHttpRequest, which has a "progress" event that correctly reports the response body bytes. You can even make a wrapper for XmlHttpRequest and call it "myFetch()" if you insist.
- leptons 2y agoThat doesn't change the fact that it is possible to use fetch with progress.
- meindnoch 2y agoSure, it is possible to use fetch() with progress, as long as Content-Encoding is not used. Which is precisely what I've said in my first comment.
- leptons 2y agoAnd I've explained why, in most cases, Content-Encoding doesn't need to be used for async download with progress monitoring.