Caching

Cadenza uses multiple caches to …​

  • Make for a more performant user experience.

  • Reduce the load for the Cadenza server and DB, thus reducing the operational costs.

  • Reduce the amount of data which is sent to the client.

The caches can roughly be separated into caching on the server and caching on the client (in the browser).

Caching on the Server

All server caches are configured via the cache-config.xml (see reference):

The maxWeight is in file size format, see Configuration Reference.

QueryResultCache

Caches all query results for Database, ArcGIS REST and WFS data sources (when used as selector or workbook data source). The weight of the cache is calculated based on the number of rows in a query result.

Default Configuration
<cache>
  <name>QueryResultCache</name>
  <restriction>
    <maxWeight>1M</maxWeight>
  </restriction>
</cache>

Maximum Caching Time

Additionally, the cached data expires after a certain amount of time that can be configured per data source in the management center. The default data source maximum caching time can be configured in the basicweb-config.xml (see reference).

The maximum caching time is a trade-off between performance and liveliness of the data: When a data source contains live data that changes frequently, we would be returning stale data to the user if the maximum caching time is too high. On the other hand if the data does not change often, and we always request it again, we waste a lot of performance.

→ We recommend setting the maximum caching time as high as the data allows, but not lower than a few seconds so that we can at least benefit from the cache when rendering a result table once.

The maximum caching time is also used for caching data source data on the client.

ResponseCache

Caches responses from external services like in the Location Finder, WMS, What3Words or ArcGIS.

Default Configuration
<cache>
  <name>ResponseCache</name>
  <restriction>
    <maxNumberOfEntries>100</maxNumberOfEntries>
  </restriction>
  <expiration>
    <afterWrite>PT15M</afterWrite>
  </expiration>
</cache>

TileImageServiceCache

Caches images from tile cache services like WMTS, OSM or ARCGIS Rest on the file system.

Default Configuration
<cache>
  <name>TileImageServiceCache</name>
  <restriction>
    <maxNumberOfEntries>10000</maxNumberOfEntries>
    <!-- Desktop: -->
    <!-- <maxNumberOfEntries>1000</maxNumberOfEntries> -->
  </restriction>
  <expiration>
    <afterAccess>PT60M</afterAccess>
    <!-- Desktop: -->
    <!-- <afterAccess>PT15M</afterAccess> -->
  </expiration>
</cache>
Each time the Cadenza server is started, a new cache directory cadenza{random}/cachedTiles is created in the system’s temp directory. The directory and its contents cannot be reliably deleted when the server is shut down. Therefore, it is recommended to check the temp directory regularly for files and directories that are no longer needed.
It is recommended to monitor this cache, because the needed size depends strongly on the average user behavior and on the number of tile cache services used.

UserDataCache

Caches user data like mail and print name that are received from services such as LDAP and Keycloak.

Default Configuration
<cache>
  <name>UserDataCache</name>
  <expiration>
    <afterAccess>PT24H</afterAccess>
  </expiration>
</cache>
By default, the cache is invalidated after 24 hours since the last query for a user, so there is a chance that stale data is shown in Cadenza.

Browser Caching

Web browsers have a built-in cache that is used to store the response to HTTP requests. Not all HTTP requests can be cached: For example a POST request cannot be cached, because it’s typically used to send data to the server. A GET request on the other hand is used - well - to get data from the server and can be cached by default. Besides that, the server can control whether and how a response to a request can be cached by the client (= browser) by adding special HTTP headers to the response. The entries of the browser cache are identified mainly by the request URL as the cache key.

By default, the Cadenza Web server does not allow caching of any requests to ensure that the client always gets fresh data. For certain use cases, this default is explicitly overridden for better performance. This can not be configured directly, except for the data source max caching age (see the QueryResultCache).

Browser Cache vs Server Cache: Why Have Both?

While the browser cache reduces the number of requests from one client, it cannot serve multiple clients, because it’s on each individual client. Because it’s on the client, it also doesn’t affect the memory consumption on the server. A server-side cache on the other hand serves multiple clients, but the data still needs to be transferred to the clients. A combination of both caches combines their benefits.

Imagine a very popular workbook table view: We need to execute that query only once on the database and subsequent requests from other users will be served from the server cache (for a certain time) as long as they don’t use different filtering. Because we also use client-side caching, the data is transferred from the server to the client only once, even if the user reloaded the page.