Minification of API responses

HI,
I was wondering whetere there were some means to minify API (or CDK) responses, which now seem “beautified”.
Something like this (just metadata).

{
  "sys": {
    "type": "Array"
  },
  "total": 1,
  "skip": 0,
  "limit": 100,
  "items": [
    {
      "metadata": {
        "tags": []
      },
      "sys": {
        "space": {
          "sys": {
            "type": "Link",
            "linkType": "Space",
            "id": "abcdefghijkl"
          }
        },
        "id": "0987654321098765432109",
        "type": "Entry",
        "createdAt": "2022-11-20T16:25:12.770Z",
        "updatedAt": "2022-12-06T11:33:40.001Z",
        "environment": {
          "sys": {
            "id": "master",
            "type": "Link",
            "linkType": "Environment"
          }
        },
        "revision": 7,
        "contentType": {
          "sys": {
            "type": "Link",
            "linkType": "ContentType",
            "id": "page"
          }
        },
        "locale": "en-US"
      },
      "fields": {
        "id": "home",
        "title": "myTitle",
        "sections": [
          {
            "sys": {
              "type": "Link",
              "linkType": "Entry",
              "id": "1234567890123456789012"
            }
          }
        ]
      }
    }
  ]
}

is 1203 bytes, while this
{"sys":{"type":"Array"},"total":1,"skip":0,"limit":100,"items":[{"metadata":{"tags":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"abcdefghijkl"}},"id":"0987654321098765432109","type":"Entry","createdAt":"2022-11-20T16:25:12.770Z","updatedAt":"2022-12-06T11:33:40.001Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"page"}},"locale":"en-US"},"fields":{"id":"home","title":"myTitle","sections":[{"sys":{"type":"Link","linkType":"Entry","id":"1234567890123456789012"}}]}}]}
is 601… half of it, for just some metadata. I’d say the longer and more complex the response is, the higher the gain in performance.

According to this gzip is enabled on all API endpoints HTTP details | Contentful which is far more effective than minification, though doing both would add little bit of an additional boost

1 Like