Last edit: 2025.12.13
TomTom Maps

Enabled by default

Since 1st December 2024 new customers receive all Intermediate Traffic Feed responses compressed with Gzip. The use of the Accept-Encoding: gzip HTTP header is recommended, but not required.

Benefits of Gzip compression

TomTom observed that Gzip compression is beneficial for several reasons:

BenefitDescription
Faster feed downloadsCompressed feeds are much smaller and therefore faster to download.
Our tests show that:
  • compressed XML-based feeds can be ~20 times smaller
  • compressed Protobuf-based feeds can be ~2 times smaller
Faster processing timeThe overall processing time of new snapshots will be greatly reduced, which results in fresher data.
  • The additional decompression step that happens client-side is really lightweight and takes little time compared to the amount of time saved by faster downloads.
  • Also consider that all Intermediate Traffic API feeds are always compressed at the source. TomTom decompresses the content before sending it to clients that don’t use Gzip. Clients that use Gzip save time by directly accessing the compressed feeds.
Easy to implementEnabling Gzip is usually straightforward because it’s supported out-of-the-box by many client libraries.

I'm still not using Gzip compression, how can I start using it?

Customers that still don't use Gzip compression can decide at any time to request the Gzip-compressed feed and receive the same content, in the same format, while leveraging the benefits of a more efficient encoding.

Follow these steps to enable Gzip compression:

  1. Configure your HTTP client: Depending on your HTTP client library, enabling compression could be just an option to set or you might need to manually add the Accept-Encoding: gzip header to HTTP requests.
  2. Test: Request a feed and verify that the content is correctly decompressed. Depending on your HTTP client library, this might happen automatically or you might need to specify a decompression handler.

Check the following instructions for common client libraries.

The following instructions are intended as general guidelines. Actual changes may vary slightly depending on the library version and your specific implementation.

cURL

Steps:

  1. Add the --compressed option (official documentation).
  2. Decompression will happen automatically.

WGET

Steps:

  1. Add the --compression=gzip option (official documentation).
  2. Decompression will happen automatically.

Java: HttpsURLConnection

Steps:

  1. Add the Accept-Encoding: gzip header to the javax.net.ssl.HttpsURLConnection instance:

    httpsURLConnection.setRequestProperty("Accept-Encoding" , "gzip");
  2. Wrap the response input stream with java.util.zip.GZIPInputStream:

    InputStream inputStream = new GZIPInputStream(httpsURLConnection.getInputStream());

Java: Jakarta Commons HttpClient

Jakarta Commons HttpClient (now renamed to “Apache HttpComponents”) transparently supports compression by default since version 4.1, but we suggest upgrading to more recent versions. See the official documentation.

If you cannot upgrade, you might need to take the following steps:

  1. Add the Accept-Encoding: gzip header to the org.apache.commons.httpclient.methods.GetMethod instance:

    getMethod.addRequestHeader("Accept-Encoding" , "gzip");
  2. Wrap the response input stream with java.util.zip.GZIPInputStream:

    InputStream inputStream = new GZIPInputStream(getMethod.getResponseBodyAsStream());

Python: ‘requests’ library

Steps:

  1. Add the Accept-Encoding: gzip header to requests:

    1import requests
    2# ...
    3request_headers = {'Accept-Encoding': 'gzip'}
    4response = requests.get(url, headers=request_headers)
  2. Decompression will happen automatically (official documentation).

Python: urllib.request module

Steps:

  1. Add the Accept-Encoding: gzip header to the urllib.request.Request (official documentation):

    1import urllib.request
    2# ...
    3request_headers = {'Accept-Encoding': 'gzip'}
    4request = urllib.request.Request(url, headers=request_headers)
  2. Add gzip.decompress to the existing code that reads the response content:

    1import gzip
    2# ...
    3response_data = gzip.decompress(response.read())