reservations-eapi icon

reservations-eapi

(0 reviews)

Compression

From July 2023 RDG have enabled support for compression within the reservations API. Prior to this date if a consumer of the API advertised in their request that they could consume a compressed response (by including 'Accept-Encoding: gzip' within the request header) this was ignored by the API and content was always returned in its native, uncompressed, form. From July 2023, if the request includes this header then content will be compressed before being returned.

Example headers in a request

POST https://api.nationalrail.co.uk/reservations/api/v1/availability HTTP/1.1
Accept-Encoding: gzip
Authorization: Bearer {{token}}
Connection: Keep-Alive
Content-Length: 2783
Content-Type: application/json
Host: api.nationalrail.co.uk
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

Response headers prior to July 2023:

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 3288
Content-Type: application/json; charset=UTF-8
Date: Thu, 06 Jul 2023 15:33:32 GMT
Strict-Transport-Security: max-age=31536000; includeSubdomains;
x-ssl-client-verify: NONE
x-correlation-id: 76af19c0-1c12-11ee-885e-06ff204a1d13
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

These headers indicate that the content is being returned without any compression

Response headers after July 2023:

HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Thu, 06 Jul 2023 15:36:56 GMT
Strict-Transport-Security: max-age=31536000; includeSubdomains;
Transfer-Encoding: chunked
x-ssl-client-verify: NONE
x-correlation-id: f047cb10-1c12-11ee-885e-06ff204a1d13
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

The headers after July 2023 now indicate that the response content has been compressed (content-encoding: gzip).

Compressing the response content makes minimal difference to small responses, but for bigger responses it can improve the response time by as much as 50%. Most HTTP modules natively handle compressed responses, so whilst requesting them is optional RDG recommend doing so wherever possible. If your systems cannot handle compressed content in the response then do not include the 'Accept-Encoding: gzip' header in the request.


Last update: 21-Jul-2023 08.30: ASSIST API Documentation Maintenance: 'reservations-eapi', Version 'v1', Page 'Compression', Revision 'A'.

To request updates to this text please contact Neil Barkham.


Reviews