ezyfox-server icon indicating copy to clipboard operation
ezyfox-server copied to clipboard

Use gzip to zip request response

Open tvd12 opened this issue 1 year ago • 3 comments

zip request, response has size > 1500 bytes

tvd12 avatar Jul 27 '23 01:07 tvd12

In http, we have Content-Encoding, Accept-Encoding headers to decide whether we should compress/uncompress the data and the codec to do that (gzip is a case). Is there any equivalent in Socket? I think we should not force user using gzip or 1500b threshold, they can choose deflate, gzip, identity based on their need. Just provide them a configuration and let them decide which is best for them

anaconda875 avatar Mar 13 '24 10:03 anaconda875

@anaconda875

  1. No, it's depending header of package, you can take a look here.
  2. yes, gzip should be optional.

tvd12 avatar Mar 14 '24 09:03 tvd12

So please consider this simple scenario: Add one more bit to req header: respCompressionRequired default false. If true, server will use gzip to compress resp (only gzip), don't care about 1500bytes. Add one more bit isCompressed to resp header. In client sdk, add 2 configuration:

  • reqCompressionRequired defaul false. If true, client compress req before sending.
  • respCompressionRequired default false. Use it to turn the bit on/off.

anaconda875 avatar Mar 14 '24 11:03 anaconda875