Firebase Realtime Database compress JSON before sending.

2,147 views
Skip to first unread message

Artak

unread,
Jul 8, 2016, 10:31:49 AM7/8/16
to Firebase Google Group
How can compress JSON before sending it to client?

Joe White

unread,
Jul 8, 2016, 1:22:43 PM7/8/16
to Firebase Google Group
Ancillary question -- doesn't this happen automatically with Firebase v3?

Artak

unread,
Jul 8, 2016, 5:22:07 PM7/8/16
to Firebase Google Group
No, I am using latest version of Firebase, and by inspecting traffic I found that data is sent uncompressed.
Downloading 2mb data takes 4 seconds, but when I am using my Rest server with gzip compression, it takes 0.5 second.

Ryan Mills

unread,
Jul 9, 2016, 8:05:31 PM7/9/16
to Firebase Google Group
Can someone from Firebase please confirm?

My understanding was this would be compressed automatically by the JS library to reduce payload size and increase response times.

Ryan

Joe White

unread,
Jul 10, 2016, 6:51:10 PM7/10/16
to Firebase Google Group
[Customer] Is this "lack of compression" because of the planned but not yet implemented "HTML 2" support in Firebase v3 elements (hosting, realtime database, etc.)?

Mike Mcdonald

unread,
Jul 10, 2016, 8:47:28 PM7/10/16
to Firebase Google Group
The current Firebase Realtime Database clients don't compress data in transit--it's a design decision we made a long time ago since for small pieces of data take longer to compress/decompress than to just send them uncompressed. There are no plans to change this, nor are there plans to upgrade the existing clients to HTTP2.

Switching to Firebase Hosting (different product, different use case: hosting website content): you can use the Content-Encoding header to allow for gzip compression, which will help download web content faster. Eventually, I believe the plan is for Firebase Hosting to support HTTP2, which will perform magic compression things under the hood, but that's a little ways off.

Thanks,
--Mike

Ryan Mills

unread,
Jul 13, 2016, 9:29:53 PM7/13/16
to Firebase Google Group
Hi Mike,

That makes sense for small pieces of data, but what about when the payload is larger?

Ryan

Mike Mcdonald

unread,
Jul 15, 2016, 4:41:24 AM7/15/16
to Firebase Google Group
Depends on what "larger" is--as I'm not sure where the cutoff for compression overhead vs file size is. That said, if you're storing multi-MB files, it might make more sense to use Storage, where you can use gzip compression.

Thanks,
--Mike

Ryan Mills

unread,
Jul 21, 2016, 7:41:23 PM7/21/16
to Firebase Google Group
Let's say -- Less than 500Kb?

Ryan
Reply all
Reply to author
Forward
0 new messages