Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

[Idea] replace json property names with ordinals to reduce bandwidth #47

Open
dcworldwide opened this issue Sep 19, 2017 · 4 comments
Open

Comments

@dcworldwide
Copy link

dcworldwide commented Sep 19, 2017

Just a thought, so we already have query -> id mapping. Would it then not be possible to extend that concept to the JSON payload property names?

I.e.

{
   orders: [
       id: "",
       customer: {...}
   ]
}

to

{
   1: [
       2: "",
       3: {...}
   ]
}

and then have apollo restore the property names?

@Poincare
Copy link
Contributor

Does this result in a significant reduction in bundle size post-gzipping?

@dcworldwide
Copy link
Author

Will test tomorrow. Presumably largest benefit would be for non gzip responses

@teakesdev
Copy link

Interesting Idea. I will give it a try on Monday.

@dcworldwide
Copy link
Author

dcworldwide commented Sep 28, 2017

A quick and dirty test on a large json file that I had.

json size test

output.json is a large json array with redundant keys
output.optimised.json re-names all keys from strings, into single/double character pseudo keys (as per OP)

This was a large file test, so the relative % difference is probably more relevant. Per request it's probably not too big a deal, but if your server needs to handle high throughput, this could make sense..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants