Method for Working with Cache

To work with cache, execute requests using the "cache" API method (determine user token before executing the request):

curl -v '<IP address or DNS server name>/api/v1/cache/' -H 'Authorization: Bearer <user token>' --header 'Accept: application/json'

The example of response:

[
  {
    "user":"<user name>",
    "device":"<device identifier>",
    "sync_datetime":"<date>",
    "version":1,"etag":
    "<ETag identifier>"
  }, ...
]

curl -v '<IP address DNS server name>/api/v1/cache/refresh/' -H 'Authorization: Bearer <user token>' --header 'Content-type: application/json' -d '{"resource_title":"<resource name>","<parameter 1 name>":<parameter 1 name>,"<parameter 2 name>":<parameter 2 name>,...,"<parameter n name>":<parameter n name>}'

The example of response:

* Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to <IP address or DNS server name> (0.0.0.0) port 80 (#0)
> POST /api/v1/cache/refresh/ HTTP/1.1
> Host: <IP address or DNS server name>
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: <user token>
> Content-type: application/json
> Content-Length: 81
>
* upload completely sent off: 81 out of 81 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.16.1
< Date: <date>
< Content-Type: application/json; charset=utf-8
< Content-Length: 73
< Connection: keep-alive
< Allow: POST, OPTIONS
< X-Frame-Options: SAMEORIGIN
< Vary: Origin, Cookie
< ETag: "<ETag identifier>"
<
* Connection #0 to host <IP address or DNS server name> left intact
{"task_id":"<task identifier>","task_state":"SUCCESS"}

If cache is updated successfully, the response returns background task identifier (task_id) task execution state (task_state). If cache is being updated, the cache update task will be executed according to the specified task order.

To get specific cache status, specify the obtained background task identifier in the request:

curl -v '<IP address DNS server name>/api/v1/cache/state/?task_id=<task identifier>' -H 'Authorization: Bearer <user token>' --header 'Content-type: application/json'

The example of response:

* Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to <IP address or DNS server name> port 80 (#0)
> GET /api/v1/cache/state/?task_id=<task_id> HTTP/1.1
> Host: <IP address or DNS server name>
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: Bearer <user token>
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.16.1
< Date: <date>
< Content-Type: application/json; charset=utf-8
< Content-Length: 73
< Connection: keep-alive
< Allow: GET, HEAD, OPTIONS
< X-Frame-Options: SAMEORIGIN
< Vary: Origin, Cookie
< ETag: "<ETag identifier>"
<
* Connection #0 to host <IP address or DNS server name> left intact
{"task_id":"<task identifier>","task_state":"PENDING"}

See also:

Server API | Cache Control