Configure the Cache
For efficiency reasons, the Open Data API automatically caches the results of queries. This means that, for example, if multiple requests are received for the same table, the API will return the results from the cache, rather than re-querying SuperSERVER.
The cache is enabled automatically by default. You should review the default settings to check whether they are appropriate for your environment and expected usage of the API. It is also possible to disable the cache if necessary, although this is not recommended.
To configure caching, edit the settings in the configuration.properties file. Make sure you edit the version of this file that is located in the Open Data API directory, rather than the SuperWEB2 version.
If your deployment uses Data Control API modules that change table results for specific users or groups then you should refer to the steps in Open Data API Cache and the Data Control API to configure the Open Data API cache to support your usage scenario.
Cache Configuration
There are three independent caches, each of which can be disabled and configured independently if required:
Authentication
This cache is intended to speed up authentication in situations where the authentication process is slow (for example where the Open Data API is separated from the authentication server by a slow network connection). If the authentication process is fast (for example on the same network and responds instantly), then you are recommended to disable this cache by setting openData.auth.cacheSize
to 0
.
You can configure:
- The maximum cache size.
- How frequently the cache expires.
By default the authentication cache will store up to 10,000 entries and expire after 10 minutes.
Table Results
This cache is intended to speed up table queries. If a request is received for a table that is already cached, the results from the cache will be returned rather than retabulating the query in SuperSERVER.
You can configure:
- The maximum size of the cache (either measured by an amount of data or by number of cached results).
- How frequently the cache expires.
- Whether or not the expiry time is reset every time a particular query is accessed.
By default the table cache will store up to 4,000 queries. Each individual entry will expire 1 day after it is accessed.
Schema
This cache is intended to speed up schema queries. If a request is received for schema elements that are cached then the results from the cache will be returned.
You can configure:
- The maximum size of the cache (either measured by an amount of data or by number of cached results).
- How frequently the cache expires.
- Whether or not the expiry time is reset every time a particular schema query result is accessed.
By default the schema cache will store up to 1,000 schema query results. Each result will expire 1 day after it is last accessed.
Clear the Cache
The cache will clear itself automatically based on the selected configuration settings. In addition, the cache will automatically be cleared in situations where you make changes to datasets, saved tables, and user permissions that invalidate the current contents. For example, if you remove a user's access to a dataset entirely, then any cached results for that dataset will be cleared for the corresponding user. Similarly, changes to Field Level Security will cause any affected cached contents to be cleared.
However, you may find you need to manually clear the cache in some cases. You can either clear the entire cache or just clear it for a specific user or dataset. To do this, send a DELETE request to the /cache
endpoint:
Endpoint | https://<server>/webapi/rest/v1/table/cache | Clear the entire table cache. |
---|---|---|
https://<server>/webapi/rest/v1/table/cache?userId=<user_id> | Clear the table cache for the specified user. | |
https://<server>/webapi/rest/v1/table/cache?datasetId=<dataset_id> | Clear the table cache for the specified dataset. | |
https://<server>/webapi/rest/v1/table/cache?userId=<user_id>&datasetId=<dataset_id> | Clear the table cache for the specified dataset for the specified user. | |
https://<server>/webapi/rest/v1/schema/cache | Clear the entire schema cache. | |
https://<server>/webapi/rest/v1/schema/cache?userId=<user_id> | Clear the schema cache for the specified user. | |
https://<server>/webapi/rest/v1/schema/cache?datasetId=<dataset_id> | Clear the schema cache for the specified dataset. | |
https://<server>/webapi/rest/v1/schema/cache?userId=<user_id>&datasetId=<dataset_id> | Clear the schema cache for the specified dataset for the specified user. | |
https://<server>/webapi/rest/v1/auth/cache | Clear the entire authentication cache | |
https://<server>/webapi/rest/v1/auth/cache?userId=<user_id> https://<server>/webapi/rest/v1/auth/cache?apiKey=<key> | Clear the authentication cache for the specified user. You can either use the user ID or their API Key. | |
https://<server>/webapi/rest/v1/auth/cache?userId=<user_id1>&userId=<user_id2> https://<server>/webapi/rest/v1/auth/cache?apiKey=<key1>&apiKey=<key2> | Clear the authentication cache for multiple users. | |
https://<server>/webapi/rest/v1/metadata/cache | Clear the metadata cache. | |
HTTP Method | DELETE |
In order to flush the cache, you must use an API Key associated with an administrator account.