RefreshObjectCaches

更新时间:
复制 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

  • Request method: POST requests are supported. Parameters are displayed in a form.

  • Related operations: The refresh and prefetch operations include the RefreshObjectCaches refresh operation and the PushObjectCache prefetch operation.

  • Maximum number of calls per user per second: 50.

  • To automate refresh or prefetch tasks, refer to Refresh and prefetch automation scripts.

Before you begin

  • After a refresh node is committed and successfully executed, the cached resources on the corresponding points of presence become invalid. When you send an access request for the resources, the points of presence perform origin fetch to retrieve the latest resources and cache the resources on the points of presence. Committing a large number of refresh nodes at a time clears a large amount of cache, which causes a spike 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. If the cache validity period configured for a file or folder is less than 5 minutes, you do not need to execute a refresh. Wait for the cached file or folder to reach timeout and update automatically.

  • To use a Resource Access Management (RAM) user to execute refresh or prefetch operations, obtain the required permissions first. Refer to Grant permissions to a RAM user for refresh and prefetch 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 Quota management. 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-stripped 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 filling out the form.

  • 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

  • When you commit multiple URLs or multiple folders at a time, separate them with line feeds.

  • The total number of domain names across all URLs in a single commit 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-stripped refresh. Parameter stripping refers to removing the ? and all characters after ? from a request URL. Parameter-stripped refresh means that you commit a parameter-stripped URL through the API. The committed URL is then matched against cached resource URLs after parameter stripping. If a cached resource URL matches the committed URL after parameter stripping, the 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.

  • File refresh directly deletes the resource from the point of presence. When a new request arrives, origin fetch is performed to retrieve the latest resource. 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 points of presence. Default value: false.

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

  • false: Marks the cache on points of presence as expired. After a cached resource is marked as expired, the next request for the resource triggers the point of presence to authenticate the resource against the origin server. If the resource is the same as the row cache version, the cached resource is returned directly. If the resource has changed, origin fetch is performed to retrieve the latest resource, return it to the user, and cache it again. This method allows gradual cache updates instead of immediate full purge. It is suitable for scenarios that require smoothing and reduces the origin server load that may result from executing a direct deletion of a large amount of cache.

Note

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

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, the nodes 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.