RefreshObjectCaches

Updated at:
Copy as MD

Refreshes file content on nodes. The cached files that are refreshed immediately become invalid. New requests retrieve the latest files from the origin server. Batch URL refresh is supported.

Operation description

Before you begin

  • After a refresh node is committed and successfully executed, the corresponding cached resources on CDN points of presence become invalid. When you send a new access request, the point of presence performs an origin fetch to retrieve the required resources and caches them again. Committing a large number of refresh nodes clears a large amount of cache, which causes spikes in origin fetch bandwidth and requests and increases the load on the origin server.

  • A refresh node takes about 5 to 6 minutes to take effect after it is committed. If the cache expiration time configured for a file or folder is less than 5 minutes, you do not need to perform a refresh operation. Wait for the file or folder cache to time out and update automatically.

  • To use a Resource Access Management (RAM) user to perform refresh or prefetch operations, obtain the required authorization first. Refer to Grant refresh and prefetch permissions to a RAM user to complete the authorization.

URL refresh quota

  • By default, each account can commit up to 10,000 URL refresh requests and 100 folder refresh requests per day. Folder refresh includes subdirectories. If the daily peak bandwidth of your Alibaba Cloud account exceeds 200 Mbit/s, you can request a higher daily quota by referring to submit a ticket. Alibaba Cloud evaluates and configures the quota based on your actual business requirements.

  • By default, each account can commit up to 20 regex-based refresh requests and 100 parameter-filtering refresh requests per day. If the daily peak bandwidth of your Alibaba Cloud account exceeds 10 Gbit/s, you can request a higher daily quota by submitting a ticket.

  • Each request can contain up to 1,000 URL refresh entries, 100 folder refresh entries, or 1 regex-based refresh entry.

  • A maximum of 10,000 URL refresh entries can be committed per minute for a single domain name.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

cdn:RefreshObjectCaches

none

*Domain

acs:cdn:*:{#accountId}:domain/{#DomainName}

None None

Request parameters

Parameter

Type

Required

Description

Example

ObjectPath

string

Yes

  • To commit multiple URLs or multiple folders at a time, separate them with line feed characters.

  • The total number of domain names across all URLs in a single committed node must not exceed 10.

http://example.com/image/1.png http://aliyundoc.com/image/2.png

ObjectType

string

No

The refresh type. Valid values:

  • File (default): URL.

  • Directory: folder.

  • Regex: regex-based refresh.

  • IgnoreParams: parameter-filtering refresh. Parameter filtering removes the ? and all characters after ? from a request URL. In a parameter-filtering refresh, you commit a URL with parameters removed through the API. The committed URL is then matched against cached resource URLs after their parameters are removed. If a cached resource URL matches the committed URL after parameter filtering, the CDN point of presence executes a refresh on the cached resource.

Note
  • For the feature description of URL refresh and folder refresh, refer to Refresh and prefetch resources.

  • A file refresh directly deletes the resource from the point of presence. When a new request arrives, the latest resource is retrieved through origin fetch. Other refresh types refresh only changed resources by default. To force a refresh, set the Force parameter to true. For more information, see the metric description of the Force parameter.

File

Force

boolean

No

Specifies whether to directly delete the cache on CDN points of presence. Default value: false.

  • true: Directly deletes the cache on CDN points of presence. This means the specified cached resources are immediately removed from all CDN points of presence. The next request for the resource must access the origin server to retrieve the latest version, which is then cached again. This ensures that all subsequent requests return the latest content after the deletion. This option is suitable for scenarios that require immediate cache updates, such as emergency security vulnerability fixes or publishing critical updates. Note that this may temporarily increase the load on the origin server because all related requests need to access the origin server.

  • false: Marks the cache on CDN points of presence as expired. After a cached resource is marked as expired, the next request for the resource triggers the CDN point of presence to authenticate the latest version through origin fetch. If the version matches the current row cache, the cached resource is returned directly. If not, the latest resource is retrieved through origin fetch, returned to the user, and cached again. This method allows gradual cache updates instead of immediate full purge. It is suitable for scenarios that require smoothing transitions and reduces the increased origin server load that may result from deleting a large amount of cache at once.

Note

This parameter takes effect only when you use folder refresh, regex-based refresh, or parameter-filtering refresh.

false

ReplicaTag

string

No

This parameter is not active.

false

Response elements

Element

Type

Description

Example

object

RefreshTaskId

string

The node ID returned for the refresh request. Multiple node IDs are separated by commas (,). The returned node IDs are merged based on the following rules:

  • Refresh nodes (at URL granularity) committed for the same domain name within the same second are merged into a single RefreshTaskId.

  • If more than 2,000 refresh nodes (at URL granularity) are committed for the same domain name within the same second, they are merged into groups of 2,000, each assigned a separate RefreshTaskId.

704222901

RequestId

string

The request ID.

D61E4801-EAFF-4A63-AAE1-FBF6CE1CFD1C

Examples

Success response

JSON format

{
  "RefreshTaskId": "704222901",
  "RequestId": "D61E4801-EAFF-4A63-AAE1-FBF6CE1CFD1C"
}

Error codes

HTTP status code

Error code

Error message

Description

400 SingleRequest.OverLimit A maximum of 1000 URLs are supported for each request.
400 InvalidObjectType.Malformed The specified ObjectType is invalid.
400 InvalidObjectPath.Malformed The specified ObjectPath is invalid.
400 QuotaExceeded.Refresh Your refresh attempts have exceeded the daily limit. Refresh quantity exceeds daily quota limit.
400 InvalidExtensiveDomain.ValueNotSupported The specified ExtensiveDomain is not supported.
400 QuotaPerMinuteExceeded.Refresh You tried to refresh too frequently, please try again later.
400 TooMany.Refresh The refresh queue is full, please try again later.
429 TooManyRequests Too many requests, please try again later

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.