#GZIP Support?

1 messages · Page 1 of 1 (latest)

brave quarry
#

Yo yo, is anyone aware of any 3rd party libs that support GZIP or is this something that is built into Vapor?

brave quarry
#

A lot of the libs i've found haven't been maintained in a very long time...

hollow monolith
#

compress-nio does support gzip i think?

brave quarry
#

Ahhhh sweet, will give this a go thanks for that my man

azure crypt
#

Note that gzip request and response compression is also built into vapor, just check app.http.server.configuration for the options

brave quarry
#

@azure crypt Ahhh ok so i can see that there's a ResponseCompressionConfiguration & RequestDecompressionConfiguration options on the configuration, if i enable both of these. Set the headers on my request and response. This should do the trick no?

azure crypt
#

Yep

#

Though note that request compression needs to be set from the sending side, and is relatively rare to see (unless you control both ends)

brave quarry
#

Will i need to handle it on the FE (within my iOS app) as well before i make/send the request? Or will these headers handle it all for me

azure crypt
#

You can set it after — the server reads the headers to see if the client is sending a compressed request and behaves accordingly

#

So add support to your server first via those options, then enable in your client to get the savings

#

Note that incompressible types (ie. images, video, etc…) will just end up wasting CPU time on the server side, so there are some sane defaults to make sure only things like JSON are compressed, leaving other types untouched

brave quarry
#

Ahhh ok so I was planning to actually use this on images 😅

azure crypt
#

You won't get much savings, and you'll use CPU time, fair warning 😅

#

(this is from experience)

brave quarry
#

Loooool ok, really appreciate you breaking this down btw @azure crypt

#

Last thing i want is to affect CPU time, so might just stick with what I have now then

azure crypt
#

I would definitely enable it for things like JSON though — there its a win win, as the CPU time is negligent compared to the time saved sending the compressed bytes

brave quarry
#

Yh i'll look into it for my JSON for sure. Again thanks for your help and explaination @azure crypt. As someone who doesn't have a lot of backend experience stuff like this is really valuable to me

inland flickerBOT
azure crypt