Baidu AI Cloud
中国站

百度智能云

CDN

Cache Management Interface

Purge Cache/Query Purge Status Purge/GetPurgedStatus

You can clear cache by URL purge or directory purge. URL refresh is to refresh cache with a file or a resource as the unit. The directory refresh is to clean the cache of all files under the directory in the unit of directory.

cli := client.GetDefaultClient()                               
                                                               
//Delete                                                          
purgedId, err := cli.Purge([]api.PurgeTask{                    
	 {                                                          
	 	 Url: "http://my.domain.com/path/to/purge/2.data",      
	 },                                                         
	 {                                                          
	 	 Url:  "http://my.domain.com/path/to/purege/html/",     
	 	 Type: "directory",                                     
	 },                                                         
})                                                             
fmt.Printf("purgedId:%+v\n", purgedId)                         
fmt.Printf("err:%+v\n", err)                                   
                                                               
//Query the removal status according to task ID.                                                
purgedStatus, err := cli.GetPurgedStatus(&api.CStatusQueryData{ 
	 Id: string(purgedId),                                      
})                                                             
                                                               
fmt.Printf("purgedStatus:%+v\n", purgedStatus)                 
fmt.Printf("err:%+v\n", err)                                   

In the example, two types of resource are removed, among which the first one is to remove a file, and the second one is to remove all files under a certain directory. Query the task progress according to the task id returned by purge. api.CStatusQueryData is a relatively complex structure. You can query based on different conditions. For details, please see the definition.

Prefetch/GetPrefetchStatus

URL prefetch is the resource warm-up with file as a unit.

cli := client.GetDefaultClient()                                    
                                                                    
prefetchId, err := cli.Prefetch([]api.PrefetchTask{                 
	 {                                                               
	 	 Url: "http://my.domain.com/path/to/purge/1.data",           
	 },                                                              
})                                                                  
fmt.Printf("prefetchId:%+v\n", prefetchId)                          
fmt.Printf("err:%+v\n", err)                                        
                                                                    
                                                                    
prefetchStatus, err := cli.GetPrefetchStatus(&api.CStatusQueryData{ 
	 Id: string(prefetchId),                                         
})                                                                  
fmt.Printf("prefetchStatus:%+v\n", prefetchStatus)                  
fmt.Printf("err:%+v\n", err)                                        

Query Purging/Prefetching Quota GetQuota

cli := client.GetDefaultClient()                 
quotaDetail, err := cli.GetQuota()               
fmt.Printf("quotaDetail:%+v\n", quotaDetail)     
fmt.Printf("err:%+v\n", err)                     

quotaDetail is an object in api.QuotaDetail type, and the details are as follows:

Field Type Description
DirRemain int Balance of the directory purge quota in the day.
UrlRemain int Refresh (including warm-up) URL residual quota in the current day.
DirQuota int Purge directory total quota
UrlQuota int Refresh (including prefetch) URL total quota
Previous
Domain Name Configuration Interface
Next
Dynamic Acceleration Interface