In my dynamic web application, I utilize ajax requests to fetch responses in JSON format.
The returned data is typically an array of objects.
Since the array often contains a large number of elements (even though the server gzip compresses the data), I opt to use very short keys in the response to minimize the size of the payload.
For instance, instead of labeling it as description:, I simply use d:, and similarly, width: becomes w:.
While this approach reduces response size, on the client side, extremely concise non-human-readable keys can make the JavaScript accessing the object less user-friendly.
The potential solution may involve parsing the response again and reconstructing the object with more descriptive keys or replacing them in the original object received. However, this might negatively impact JavaScript performance, leading to delays.
Is there a better alternative?
UPDATE:
Upon the suggestion from Björn Roberg in the comments, I conducted a comparison:
pretty-response.json 459,809 bytes
short-response.json 245,881 bytes
pretty-response.json.zip 28,635 bytes
short-response.json.zip 26,388 bytes
As the server compresses the response, the disparity between the two sizes is minimal.
However, opting for a pretty response means that the server needs to compress 450 KB of data, while a short response only requires 240 KB.
Can this affect server performance (or is there a way to gauge it)?