Cache Configuration

Caching results can improve the performance of an application and reduce the server load a lot. Please note the difference between server-side and client-side caching, both of which are described below.

Server-side Tile Caching

Map tiles can be cached on the server side, instead of redrawing the tiles for every request. There are multiple proxy and cache technologies and products available. Because of ist simple configuration and its great spread, we describe a tile cache implementation based on the nginx HTTP server.

Prerequisites

Download the latest nginx version and install it.

Configuration

Client-side Caching

Redundant requests can be served from the client's cache, which reduces the workload for the server. For the Map Tile API and Routing REST requests, the PTV xServer 2 can set HTTP response header directives accordingly.

Configuration

The HTTP response header directives set in the RESTClosed REST (Representational State Transfer) represents a World Wide Web paradigm, consisting of constraints to the design of components which results in a better performance and maintainability. responses can be configured in the xserver.conf:


        core {
            [...]

            cacheControl {
                maximumAge = 86400
            }
        }
    

By default, the maximum age for cached responses on client-side is set to 24h.

With the default settings shown above, the cache header of the response to the xMap tile request http://hostname:50000/services/rest/XMap/tile/13/4238/2790 is valid for 24 hours:


            cache-control: public, max-age=86400
            content-length: 7705
            content-type: image/png
            [...]
        

On the other hand, xMap and xRoute REST requests with

may have dynamically changing data and therefore will not be cached:


            cache-control: no-cache, no-store, must-revalidate
            content-length: 1615
            content-type: image/png
            [...]