[yew-devel] [PATCH http-server 1/1] api server: add 'wasm' as valid extension
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Jul 15 21:17:30 CEST 2025
Am 15.07.25 um 12:57 schrieb Dominik Csapak:
> On 7/15/25 11:26, Thomas Lamprecht wrote:
>> Am 14.07.25 um 14:05 schrieb Dominik Csapak:
>>> On 7/14/25 14:00, Shannon Sterz wrote:
>>>> On Thu Jul 10, 2025 at 12:28 PM CEST, Dominik Csapak wrote:
>>>>> otherwise the server won't serve wasm files to the client.
>>>>>
>>>>> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
>>>>> ---
>>>>> src/PVE/APIServer/AnyEvent.pm | 1 +
>>>>> 1 file changed, 1 insertion(+)
>>>>>
>>>>> diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
>>>>> index 8f2c3ff..b00e074 100644
>>>>> --- a/src/PVE/APIServer/AnyEvent.pm
>>>>> +++ b/src/PVE/APIServer/AnyEvent.pm
>>>>> @@ -431,6 +431,7 @@ my $file_extension_info = {
>>>>> mp3 => { ct => 'audio/mpeg', nocomp => 1 },
>>>>> oga => { ct => 'audio/ogg', nocomp => 1 },
>>>>> tgz => { ct => 'application/x-compressed-tar', nocomp => 1 },
>>>>> + wasm => { ct => 'application/wasm' },
>>>>
>>>> just a quick question: do you intend to serve the mobile quarantaine as
>>>> pure wasm or as a gzip-ed archive like we do now for pdm & peat? because
>>>> in the later case, the content type "application/octet-stream" is fine
>>>> to my understanding anyway.
>>>
>>> currently i have it served as wasm but it'll be compressed by
>>> the proxy daemon on the fly.
>>
>> Seems like a waste of resources compared to a plain sendfile when
>> doing the compression on build like in PDM. We naturally do not
>> have any usage numbers, but there are some bigger known deployments,
>> so this might see some usage.
>>
>>> imho if we'd want to precompress it, I'd add
>>> 'wasm.gz' for example as an additional content type
>>>
>>> Ideally, we could precomress it in a way that the browser still gets the correct
>>> content-type (wasm) and the http response has the right content-encoding header
>>> (gzip) but that would require a bit of work in the api server I think
>>
>> But is that always correct?
>
> what do you mean? if the file is a gzip compressed wasm. setting
> the content-encoding to gzip and content-type to wasm seems to be the right choice?
Yeah, you're obviously right, sorry for the noise.
>
>> Anyhow, for now using something like
>> DecompressionStream + manually setting the content type in the
>> header (which just improves performance) would be enough IMO.
>
> So like we do it in pdm? Sure, we can do that.
Yes, or if there something wrong/suboptimal with the way I did it there
it naturally would be good to use the better method for both sides.
> just to note that we do compress the remaining resources in pve/pmg on the fly
> (js/css/etc. which add up to a few megabyte too)
The bit of JS here probably is not really significant I'd think?
Bu sure, any other such resource might be nice to have (pre-)compressed
too if it saves a few MiB–that adds up quickly and if one has to use
a spotty uplink with a few seconds latency and 100 KiB/s those few
MiB less can be quite the time saver.
That said, we certainly do not need to block this on that, especially as
the quarantine view is really small, so not such high cost we had with PDM
or PEAT.
And doing some upfront compression should be probably done as separate
patch series checking out all products anyway.
More information about the yew-devel
mailing list