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.
Create a cache setting
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.
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:
The signature of createCacheSetting:
Parameters
| 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. |
Get cache settings
getCacheSettings lists the cache settings of an application, one page at a time.
Returns an AzionApplicationCollectionResponse whose data.results holds AzionCacheSetting objects.
Output:
The signature of getCacheSettings:
Parameters
| 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. |
Get a cache setting
getCacheSetting returns one cache setting of an application by its ID.
Returns data as an AzionCacheSetting.
Output:
The signature of getCacheSetting:
Parameters
| 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. |
Update a cache setting
updateCacheSetting sends the cache setting fields you pass in a PATCH request.
Returns data as the updated AzionCacheSetting. A payload without enum fields, such as name and a TTL, type-checks in TypeScript.
Output:
The signature of updateCacheSetting:
Parameters
| 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. |
Delete a cache setting
deleteCacheSetting deletes a cache setting of an application by its ID.
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:
The signature of deleteCacheSetting:
Parameters
| 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. |