Refreshes files on Alibaba Cloud CDN points of presence (POPs). After files are refreshed, the original file content immediately becomes invalid. If clients request the original file content, Alibaba Cloud CDN forwards the requests to the origin server. Then, Alibaba Cloud CDN caches the latest content to the POPs and returns the content to the clients. Alibaba Cloud CDN allows you to refresh content from multiple URLs at the same time.

Description

  • Alibaba Cloud CDN supports POST requests in which parameters are sent as a form.
  • You can call the RefreshObjectCaches operation to refresh content and call the PushObjectCache operation to prefetch content.
  • You can call this operation up to 50 times per second per account.
  • For more information about how to automate refresh or prefetch tasks, see Prefetch and refresh task scripts.

Precautions

  • After a refresh task is submitted and completed, specific resources are removed from POPs. When a POP receives a request for the removed resources, the POP forwards the request to the origin server to retrieve the resources. The retrieved resources are returned to the client and cached on the POP. Multiple refresh tasks may cause a large number of resources to be removed from the POPs. This increases the number of requests that are forwarded to the origin server. The back-to-origin routing process consumes more bandwidth resources and the origin server may be overwhelmed.
  • A refresh task takes approximately five to six minutes to take effect. If the cache expiration time that you specified for the resources cached on POPs is less than five minutes, you do not need to perform the refresh operation. Wait until the cache expiration time ends.
  • If you want to use RAM users to refresh or prefetch resources, you must grant the RAM users the permissions to prefetch and refresh resources. For more information, see Authorize a RAM user to prefetch and refresh resources.
Refresh quota
  • By default, each Alibaba Cloud account can refresh content from up to 10,000 URLs and 100 directories per day. The directories include subdirectories. If the daily peak bandwidth of your Alibaba Cloud account exceeds 200 Mbit/s, you can submit a ticket to request a quota increase. Alibaba Cloud reviews your request and then increases the quota based on your request.
  • By default, each Alibaba Cloud account can submit up to 20 refresh rules that contain regular expressions per day. If the daily peak bandwidth of your Alibaba Cloud account exceeds 10 Gbit/s, you can submit a ticket to request a quota increase.
  • You can specify up to 1,000 URL refresh rules, 100 directory refresh rules, or 1 refresh rule that contains regular expressions in each call.
  • You can refresh up to 1,000 URLs per minute for each domain name.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes RefreshObjectCaches

The operation that you want to perform. Set the value to RefreshObjectCaches.

ObjectPath String Yes http://example.com/image/1.png\nhttp://aliyundoc.com/image/2.png

The URLs from which content is refreshed. Format: Accelerated domain name/Paths or directories of files that you want to refresh.

Separate multiple URLs with line feed characters (\n) or a pair of carriage return and line feed characters (\r\n).

ObjectType String No File

The type of the object that you want to refresh. Valid values:

  • File: refreshes one or more files.
  • Directory: refreshes the files in one or more directories.
  • Regex: refreshes content based on regular expressions.

If you set the ObjectType parameter to File or Directory, you can view Refresh and prefetch resources to obtain more information. If you set the ObjectType parameter to Regex, you can view Configure URL refresh rules that contain regular expressions to obtain more information.

If you set the ObjectType parameter to Directory, the resources in the directory that you want to refresh are marked as expired. You cannot delete the directory. If clients request resources on POPs that are marked as expired, Alibaba Cloud CDN checks whether the resources on your origin server are updated. If resources are updated, Alibaba Cloud CDN retrieves the most recent version of the resources and returns the resources to the clients. Otherwise, the origin server returns the 304 status code.

Response parameters

Parameter Type Example Description
RefreshTaskId String 704222904

The ID of the refresh task. If multiple tasks are returned, the IDs are separated by commas (,). The task IDs are merged based on the following rules:

  • If the tasks are specified for the same accelerated domain name, submitted within the same second, and run to refresh content based on URLs instead of directories, the task IDs are merged into one task ID.
  • If the number of tasks that are specified for the same accelerated domain name, submitted within the same second, and run to refresh content based on URLs instead of directories exceeds 2,000, every 2,000 task IDs are merged into one task ID.
RequestId String D61E4801-EAFF-4A63-AAE1-FBF6CE1CFD1C

The ID of the request.

Examples

Sample requests

http(s)://cdn.aliyuncs.com/?Action=RefreshObjectCaches
&ObjectPath=http://example.com/image/1.png\nhttp://aliyundoc.com/image/2.png
&ObjectType=File
&<Common request parameters>

Sample responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<RefreshObjectCachesResponse>
<RefreshTaskId>704222904</RefreshTaskId>
<RequestId>D61E4801-EAFF-4A63-AAE1-FBF6CE1CFD1C</RequestId>
</RefreshObjectCachesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

HTTP status code Error code Error message Description
400 InvalidObjectType.Malformed The specified ObjectType is invalid. The error message returned because the value that is specified for the ObjectType parameter is invalid.

For a list of error codes, visit the API Error Center.