缓存配置接口
更新时间:2023-05-16
设置缓存过期规则
public void setDomainCacheTTL(CdnClient client) {
String domain = "my.test.com";
SetDomainCacheTTLRequest request = new SetDomainCacheTTLRequest()
.withDomain(domain)
.addCacheTTL(new CacheTTL().withType("suffix").withValue(".jpg").withTtl(3600))
.addCacheTTL(new CacheTTL().withType("suffix").withValue(".png").withTtl(3600))
.addCacheTTL(new CacheTTL().withType("path").withValue("/").withTtl(86400).withWeigth(5));
client.setDomainCacheTTL(request);
}
查询缓存过期规则
public void getDomainCacheTTL(CdnClient client) {
String domain = "my.test.com";
GetDomainCacheTTLResponse response = client.getDomainCacheTTL(domain);
}
设置缓存参数过滤规则
public void setDomainCacheFullUrl(CdnClient client) {
String domain = "my.test.com";
SetDomainCacheFullUrlRequest request = new SetDomainCacheFullUrlRequest()
.withDomain(domain)
.withCacheFullUrl(false).addCacheUrlArgs("a");
client.setDomainCacheFullUrl(request);
}
查询缓存参数过滤规则
public void getDomainsCacheFullUrl(CdnClient client) {
String domain = "my.test.com";
GetDomainCacheFullUrlResponse response = client.getDomainCacheFullUrl(domain);
}
设置自定义错误码页面
public void setDomainErrorPage(CdnClient client) {
String domain = "my.test.com";
ErrorPage errorPage404 = new ErrorPage(404, "/customer_404.html", 302);
ErrorPage errorPage403 = new ErrorPage(403, "/custom_403.html");
client.setDomainErrorPage(new SetDomainErrorPageRequest()
.withDomain(domain).addErrorPage(errorPage404).addErrorPage(errorPage403));
}
查询自定义错误页面
public void getDomainErrorPage(CdnClient client){
String domain = "my.test.com";
GetDomainErrorPageResponse response = client.getDomainErrorPage(domain);
}
设置移动访问控制
public void setDomainMobileAccess(CdnClient client){
String domain = "my.test.com";
MobileAccess mobileAccess = new MobileAccess().withDistinguishClient(true);
client.setDomainMobileAccess(new SetDomainMobileAccessRequest()
.withDomain(domain).withMobileAccess(mobileAccess));
}
查询移动访问控制
public void getDomainMobileAccess(CdnClient client){
String domain = "my.test.com";
GetDomainMobileAccessResponse response = client.getDomainMobileAccess(domain);
}
设置缓存共享
public void setDomainCacheShare(CdnClient client) {
String domain = "my.test.com";
CacheShare cacheShare = new CacheShare().withEnabled(false);
client.setDomainCacheShare(new SetDomainCacheShareRequest()
.withDomain(domain)
.withCacheShare(cacheShare));
}
查询缓存共享
public void getDomainCacheShare(CdnClient client){
String domain = "my.test.com";
GetDomainCacheShareResponse response = client.getDomainCacheShare(domain);
}
设置URI重写
public void setDomainUrlRules(CdnClient client) {
String domain = "my.test.com";
UrlRule urlRule = new UrlRule().withAction("redirect")
.withSrc("\/data\/(.*)").withDst("${1}\/data2222");
client.setDomainUrlRules(new SetDomainUrlRulesRequest().withDomain(domain).addUrlRule(urlRule));
}
查询URI重写
public void getDomainUrlRules(CdnClient client){
String domain = "my.test.com";
GetDomainUrlRulesResponse response = client.getDomainUrlRules(domain);
}