Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  26] [ 1]  / answers: 1 / hits: 43331  / 11 Years ago, thu, october 10, 2013, 12:00:00

JSON.stringify is obviously not very space efficient. For example, [123456789,123456789] occupy 20+ bytes when it could need just around 5. Does websocket compress its JSONs before sending to stream?


More From » json

 Answers
13

WebSocket is, at its heart, just a set of framing for TEXT or BINARY data.


It performs no compression on its own.


However, the WebSocket spec allows for Extensions, and there have been a variety of compression extensions in the wild (the formalized specs for one of these is finalized).


As of today (August 2018) the accepted compression spec is permessage-deflate.


Some of the extensions seen in the wild:



  • permessage-deflate - the name of the formalized spec for using deflate to compress entire messages, regardless of the number of websocket frames.

  • x-webkit-deflate-frame - an early proposed compression that compresses each raw websocket data frame. Seen in use by Chrome and Safari. (now deprecated in Chrome and Safari)

  • perframe-deflate - a renamed version of the above compression. Seen in use by various websocket server implementations, and also briefly showed up in various WebKit based clients. (Completely deprecated in modern browsers, but does still show up in various WebSocket client libraries)


Of note, the permessage-deflate extension is the first in a line of PMCE (Per-Message Compression Extensions) that will eventually include other compression schemes (ones being discussed are permessage-bzip2, permessage-lz4, and permessage-snappy)


[#75092] Wednesday, October 9, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleykeyshawnb

Total Points: 281
Total Questions: 99
Total Answers: 111

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;