I have a PHP script that makes a query to a webservice. I want the results of this query to be inserted into a row in a Firebase realtime database. This firebase database is then being monitored for changes by an Android app.
The amount of text per row can often be 800 Kb, so I would like to compress this. Otherwise my app will need to have to download 800 Kb before the OnDataChanged event happens.
What I have done is as follows (in the PHP script)
I accept the 800Kb string form the web service. I then run GZip on it in the PHP script. With the result, I then use Base64_Encode and this is what I insert the result to Firebase.
It seems to work fine, and I seem to get around 90% compression, meaning only 80Kb inserted rather than 800Kb. It is however a "round the houses" way to do this.
Is there a better way to do this? Surely there must be. Is there any way to get Firebase to GZip the string is is sending to my app? After all the app is using the Firebase SDK.
Here is the PHP code that writes to Firebase...
$compressed_gzipjson = gzencode($jsonresponse, 9);
$firebase->set(DEFAULT_PATH . '/' , base64_encode($compressed_gzipjson));
Any advice very welcome indeed.