All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

SetCacheRuleConfig

Last updated:2021-03-17 10:56:24

SetCacheRuleConfig

Description

You can call this operation to configure cache policies for a domain name. No cache policies are configured by default after a domain name is added.

Notes:

  • The cache policies of a domain name are updated in overwriting mode. All policies must be submitted for modification, including those to be or not to be modified.
  • If caching is disabled, Kingsoft Cloud CDN caches no content. If caching is enabled, Kingsoft Cloud CDN caches content even if the cache time is 0s. When Kingsoft Cloud CDN receives an access request from a user, Kingsoft Cloud CDN initiates If-Modified-Since back-to-origin verification and determines whether the origin content changes based on the Last-Modified parameter returned by the origin server. A. If the origin content changes, Kingsoft Cloud CDN obtains the requested content from the origin server and returns the content to the user. B. If the origin content has not been changed, the origin server returns the HTTP status code 304. Kingsoft Cloud CDN returns the cached content to the user. If the origin server does not support If-Modified-Since back-to-origin verification, Kingsoft Cloud CDN may return the cached content to the user.

Request syntax

The API request contains the specified directory /2016-09-01/domain/SetCacheRuleConfig, common request headers, and operation-specific request parameters. For more information, see the sample request.

Request parameters

Parameter Required Type Description
DomainId Yes String The ID of the domain name.
CacheRules Yes CacheRule[] The array of cache policies. The array is ordered. The priorities of items in the array are sorted by input sequence. The cache policy entered first has the top priority.

CacheRule

Parameter Required Type Description
CacheRuleType Yes String The type of the cache policy. For more information about the enumeration types, see Usage notes.
Value Yes String The content of the cache policy. If the type of the cache policy is directory, you can specify only one directory at a time, and the directory must start and end with a slash (/). If the type of the cache policy is exact, you can specify only one exact path at a time, and the exact path must start with a slash (/). If the cache policy type is file_suffix, you can specify multiple file name extensions separated with commas (,).
CacheEnable No String Specifies whether to enable caching. Valid values: on and off. Default value: on. If the CacheEnable parameter is set to on, the CacheTime parameter is required, and the RespectOrigin parameter is optional. If the CacheEnable parameter is set to off, the CacheTime and RespectOrigin parameters are ignored.
CacheTime No Long The cache time. Unit: seconds. This parameter is required if the CacheEnable parameter is set to on.
RespectOrigin No String Specifies whether to follow the configuration of the origin server. Valid values: on and off. Default value: on.

Examples

Sample request

POST method:

 POST /2016-09-01/domain/SetCacheRuleConfig
 Host: cdn.api.ksyun.com
 X-Amz-Date: date 
 Authorization:authorization string 
 x-action: SetCacheRuleConfig 
 x-version: 2016-09-01 
 Content-Type: application/json

{
    "DomainId":"2D09XC0",
    "CacheRules":
    [{
         "CacheRuleType":"directory",
            "Value":"/XXX/",
            "CacheTime":11,
            "RespectOrigin":"",
            "CacheEnable":"on"
    },
    {
          "CacheRuleType":"exact",
            "Value":"/XXX/XXX.TXT",
            "CacheEnable":"off"
    }]
}

Sample response

  • Note: If this operation is successfully called, the HTTP status code 200 is returned, without a return value. If this operation fails to be called, the HTTP status code 403 or 400 is returned. For more information about the error codes for the HTTP status code 400, see Usage notes.
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback