-
Notifications
You must be signed in to change notification settings - Fork 23
Admin api config and clearing cache
Content from a word document(PxWeb_REST_API.docx) written Statistics Finland
PxWeb provides a REST API for clearing cache items for authenticated clients. This is useful when some cached information is changed i.e. a batch job that creates new items that need to be visible in the API and in the UI immediately. The REST API allows a client to clear the cache items at once by performing a DELETE request.
Example request: https://{pxweb_domain_name}/api/admin/v1/cache
HTTP Method: DELETE
Headers: APIKey: {API key value}
To allow an access for a certain client add an APIKey into appsettings or into environmental variables. This APIKey is then shared with the trusted client that appends it in the headers of the DELETE request.
Example of web.config appsettings:
<add key="APIKey" value="foobar" />
Example of setting an environmental variable in Windows CMD:
set APIKey=foo
To restrict the access of the API for certain IP addresses configure the allowed addresses in settings.config.
Example configuration allowing access from localhost:
<administration>
<useIPFilter>True</useIPFilter>
<ipAddresses>
<ipAddress>127.0.0.1</ipAddress>
<ipAddress>::1</ipAddress>
</ipAddresses>
</administration>
REST API calls are logged into pxweb.log file. The log file can be searched with keyword PXWeb.API.CacheController to find log entries related to the cache clearing functionality.