Hacker News new | past | comments | ask | show | jobs | submit login

If the author decides to use the URL hash instead, he can avoid users sending that zip to his server

i.e.

   https://smolsite.zip/#UEsDBB...



I'm guessing the code to read the zip file is server-side, but I guess JS could do it too.


Yeah, server-side is much easier to code. But it should be doable with JS

I've already built a website that read zip files client-side with JS here: https://madacol.github.io/ozempic-dicom-viewer/ . It will read the zip file and search for MRI/CT scan images to display

Where I have doubts is how to reference external files from the main `index.html` file. I know you can load files as blobs and get a URL (I did that in my website above), but I am not sure if that will work as references in the <head>


Then it would require JavaScript and wouldn't be a nice demonstration for my web server library. :)


You told in another comment that the files are not decompressed on the server. Then if you don't require JS, where is the decompression happening?


On the client.

Data is already stored in the ZIP file deflated, so I can just send whatever is inside the ZIP file back to the client if they accept that encoding (which is pretty much always the case, given how ubiquitous deflate is).

The server parses the ZIP file and stores that information in a hash table for quicker lookup but it's otherwise not decompressing anything. This hash table is kept for a few minutes to avoid having to decode the base64-encoded data and parse the ZIP file for every request.


That's nice!

So decompression is happening on the client, but not at the JS level, instead you are taking advantage of browser's ability to accept zip-encoded content from the server, hence decompression is done the by browser's own behavior when it receives a "content-encoding: gzip" stream or something like that.


Use hash and avoid unnecessary work - good advice dude!




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: