Cache settings
The azion/applications functions that create, list, read, update, and delete the cache settings of an application.
These azion/applications functions create, list, read, update, and delete the cache settings of an application. The application must have an origin first: on an application with none, the API refuses the cache setting with HTTP error! Status: 400 - BAD REQUEST.
createCacheSetting
Creates a cache setting in an application. The application must have an origin first. On an application with none, the API refuses the cache setting, and the function returns error with the message HTTP error! Status: 400 - BAD REQUEST.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
data | ApiBaseCacheSettingPayload | Yes | The settings of the cache setting. name is required. |
options | AzionClientOptions | No | Request options. |
browser_cache_settings takes honor, override, or ignore, and cdn_cache_settings takes honor or override. With override, the sample also sets the matching maximum TTL field, browser_cache_settings_maximum_ttl or cdn_cache_settings_maximum_ttl.
Returns data as the created AzionCacheSetting, with its id.
This sample is JavaScript, because TypeScript rejects string values for browser_cache_settings and cdn_cache_settings, whose types are enums the module does not export:
Output:
getCacheSettings
Lists the cache settings of an application, one page at a time.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
params | ApiListCacheSettingsParams | No | Pagination: page and page_size. Leave out sort and order: the API refuses the values the type declares for them with a 400 error. |
options | AzionClientOptions | No | Request options. |
Returns an AzionApplicationCollectionResponse whose data.results holds AzionCacheSetting objects.
Output:
getCacheSetting
Returns one cache setting of an application by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
cacheSettingId | number | Yes | The ID of the cache setting. |
options | AzionClientOptions | No | Request options. |
Returns data as an AzionCacheSetting.
Output:
updateCacheSetting
Sends the cache setting fields you pass in a PATCH request.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
cacheSettingId | number | Yes | The ID of the cache setting to update. |
data | ApiUpdateCacheSettingPayload | Yes | The fields to change. Every field is optional. |
options | AzionClientOptions | No | Request options. |
Returns data as the updated AzionCacheSetting. A payload without enum fields, such as name and a TTL, type-checks in TypeScript.
Output:
deleteCacheSetting
Deletes a cache setting of an application by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
cacheSettingId | number | Yes | The ID of the cache setting to delete. |
options | AzionClientOptions | No | Request options. |
A successful delete returns error with the message Expected JSON response, but got: , so the sample reads the cache setting back with getCacheSetting. A 404 error confirms the delete.
Output: