What happens during deployment?

Hello,

I work on a Blazor Wasm PWA with Ahead-of-time-compilation enabled.

In Visual Studio, I do a publish build to folder and I upload this folder to Netlify. On the Netlify site, I see all the files in the " Deploy file browser". There are the files dotnet.wasm (29MB) and MyApp.dll (4496KB). But when I examine the Browser cache, those files are significantly smaller: 7270KB and 341KB.

How can this be?

Thanks

Philipp

This is the explanation:

If there are questions, @Philipp, please let us know.

Very informative Luke, thanks.
So, do you mean, the file MyApp.dll I see in the browser cache is in fact a file MyApp.dll.compressed?
I tried to find out the compression format, but could not make it. Do you know, what it is? I cannot open it with 7-zip.

Hi, @Philipp. it is compressed in transit and then the browser automatically decompresses it before using the data. The version that exists in the browser cache or that is used by the browser is already decompressed again. Unless something is misconfigured (and I do not believe anything is), you will never need to manually decompress any data sent.

The decompression is done automatically by the browser. The version of the file MyApp.dll you see in the browser cache is the decompressed version already.

Thanks again Luke.

It is clear that I do not have to decompress anything manually. But here are the facts again, that I rechecked just now:

  • I went to the “Deploy File Browser” on https ://app.netlify.com/sites/…
  • I searched for “MyApp” and found the not compressed MyApp.dll (4496 KB) as well as the compressed versions MyApp.dll.br (273 KB) and MyApp.dll.gz (444 KB). Those file are of course also present on my local harddrive.
  • I opened MyApp in the browser and deleted all cache data.
  • I opened the app ChromeCacheView and let it show me only the cache from “now” on. The list was empty.
  • I opened MyApp again.
  • I refreshed ChromeCacheView and from the above mentioned three files, I saw only MyApp.dll. That is okay for me, but it has a file size of 341 KB, what is none of the above file sizes.

Luke, above you wrote, that the file I

The file extension is not .br or .gz but the file size is really small compared to my original.

And that’s what I want to understand. What is going on here?

I just examined the Devtools Network tab and found the file MyApp.dll with a file size 351kB. This is not a typo, it is really not the 341KB I mentioned in my previous post, but maybe it is a matter of “KB” (1024 bytes = 1kB) vs. “kB” (1000 bytes = 1kB) and a rounding tolerance.

But the more interessting thing is: I hovered over the file size on the Network tab and the tooltip tells me “351 kB transferred over network, resource size: 4.6 MB”. That’s pretty close to my 4.4 MB and maybe also has something to do with 1024 vs 1000.
(4.4 / 1000 / 1000 * 1024 *1024 = 4.6, so maybe Netlify’s unit “MB” is not the same as Chrome’s unit “MB”)

The Network tab also tells me, that the encoding of MyApp.dll is brotli. But the file size is totally different from the file size in the Netlify Deploy File Browser: MyApp.dll.br (273 KB).
So, could it be, that Netlify does not use the brotli, I provide (273 KB) but compresses the original file itself as brotli but with different compression level, what results in 341 KB?

Hi, @Philipp. I can examine the URL in question to find the answer. What is the URL exhibiting this behavior?

I sent you a PM.
Philipp

Hi, @Philipp.

I looked at the files in your deploy and Netlify will not use the pre-compressed versions (the MyApp.dll.br version) because the request the browser makes does not include that file extension. This pre-compression of files is something people often try to get working at Netlify but we simply just do not support it out of the box.

There is another thread where people discuss the possibility of doing this using edge functions here:

You can do this manually by writing custom edge functions.

Would using your version save 20% of the bandwidth used for transferring that file? Yes, it would. However, Netlify is not designed to do this and getting that working is non-trivial. That said, it can be done and the effort required is not herculean either.

The point that I am making is that this 20% difference for this file is likely not going to be a game changer for this site. It could be but probably not.

Is the saving of 68 KB per site load worth spending the time coding a custom solution for this? I personally would not spend time working on that but my priorities may differ from yours. Please feel free to use an edge function to accomplish this if you want to do so.

If you have questions about using edge functions to make Netlify use the pre-compressed version, please let us know. (There are some details and an example edge function in the post above.)

Hi Luke,

I am totally with you. Using my pre-compressed brotli file does not make sense, since the save in bandwidth is small. But that’s not what I wanted to achieve.

I just want to know, what file format the MyApp.dll (341KB or 351kB) in the browser cache is. If I got things right, Netlify compresses the original MyApp.dll (4496KB) before deploying it and the browser decompresses it.
You said

But how can it then be that small, 341KB vs. 4496KB?

If it is still compressed, can I take the browser version of MyApp.dll and decompress it manually. I know that I do not have to do this, but I would like to know the compression format and which tool I could use for decompression. WinRar and 7-Zip cannot open the file.

Thanks again for your persistant support.

This is not true. The correct statement is:

When the file is requested and the browser supports accepting a compressed format, Netlify will compress the file while sending it to the browser. You can disable accepting compressed responses in the browser or use some other tool like curl or Postman to inspect that behaviour.

Sadly, this statement:

…is incorrect. Browser will cache the compressed version, not the uncompressed version.

As for uncompressing the file, that’s not something we can help with. I’d advise asking the developers of the browser on how to uncompress those files.

Thanks for clarification Hrishikesh.
And thanks again Luke for your help.

BR

Philipp

Hi, @Philipp. You are most welcome. I also want to point out that my colleague is being a bit pedantic below:

Is it technically stored on the local disk compressed? Yes, the compressed version is on the hard drive.

However, the browser will never give you the compressed version. If you open the cached file in the browser, it is always automatically uncompressed there. If you download the cached file from the browser cache, the copy that will be saved to a new file will be uncompressed.

The browser will always allow you to use the uncompressed version. The fact that it is stored compressed is invisible to end users. End users will always and only see the uncompressed version.

This is why I said that comment was pedantic.

While it is technically true, it does not change that the locally cached version you will use in the browser will always and automatically be the uncompressed version. I did not want that comment above to mislead you about this behavior (that the file is always uncompressed automatically by the browser).

It is compressed in transit. It is compress in the cache, until it is used by the browser. The version you will see in the browser is always the uncompressed version.

If you download the files from the browser (not looking at them in the cache), you will find that they have the exact same size as the files in the Deploy file browser at Netlify. If you find some way to download them from the cache and they are still compressed after doing so, please share the step by step instructions to do so here (as that should not be happening).

Hi Luke,

you say:

I was not able to download the file, since there is no “save as…” option and it is not listed on the network tab.
Never mind, you’ve helped a lot in understanding what’s going on. Many thanks.

BR

Philipp