百度智能云

All Product Document

          CDN

          Set the Cache Expiration Rules

          This interface is used to update the cache policy of the specified accelerated domain name. The domain name shall belong to the user, otherwise it returns 404 failure.

          Method Path Description
          PUT /v2/domain/{domain}/config?cacheTTL Modify the cache policy for the accelerated domain name file type

          Request body

          Parameter Optional Type Description
          cacheTtl Required CacheTTL List of cache rules

          CacheTTL

          Parameter Optional Type Description
          type Required String "suffix" means the file name suffix, “path" means the directory in the url, “origin " means the origin server rule. There is only one such rule, and only the weight is required. The value is “-", and ttl is 0. “code" means exception code cache. For example, you can configure 404 to cache 100 s. “exactPath" means the path is completely matched.
          value Required String Configuration rules of the specified type
          weight Optional Int Weight, an integer between 0-100. The higher the weight, the higher the priority. The default is 0, and the priority is of no use when it is code type and can be ignored.
          ttl Required Int Cache duration, in seconds

          Response code (Http Status Code)

          HTTP Status Code Description
          200 Success

          Request example

          PUT /v2/domain/myself.baidu.com/config?cacheTTL HTTP/1.1 
          Host: cdn.baidubce.com 
          Content-Length: 145
          Content-Type: text/json;utf-8
           
          { 
              "cacheTTL": 
              [ 
                  {"type": "suffix", "value": ".jpg", "ttl":36000, "weight": 30}, 
                  {"type": "suffix", "value": ".mp4", "ttl":36000, "weight": 30}, 
                  {"type": "path", "value": "/path/to/my/file", "ttl":1800, "weight": 5} 
              ] 
          } 

          Response example

          HTTP/1.1 200 OK 
          Content-Length: 190
          Content-Type: application/json;utf-8
          x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
          Server: BCE-CDN
          Previous
          Advanced Setting Interface
          Next
          Query the Cache Expiration Rules