内容分发网络CDN

    缓存配置

    设置缓存过期规则

    def test_set_domain_cache_ttl(self):
        """
        test_set_domain_cache_ttl
        """
        error = None
        try:
            rules = []
            rules.append({'type':'suffix', 'value': '.jpg', 'ttl': 3600, 'weight': 30})    # .jpg后缀缓存一小时
            rules.append({'type':'path', 'value': '/a/b/c', 'ttl': 1800, 'weight': 15})    # /a/b/c/目录下所有文件缓存1800秒
            response = self.cdn_client.set_domain_cache_ttl('opencdn3.sys-qa.com', rules)
            print response
        except BceServerError as e:
            error = e
        finally:
            self.assertIsNone(error)

    设置缓存参数过滤规则

    def test_set_domain_cache_full_url(self):
        """
        test_set_domain_cache_full_url
        """
        error = None
        try:
            response = self.cdn_client.set_domain_cache_full_url('opencdn3.sys-qa.com', True)
            print response
        except BceServerError as e:
            error = e
        finally:
            self.assertIsNone(error)

    查询缓存参数过滤规则

    def test_get_domain_cache_full_url(c):
        """
        test get domain cache full url
        """
        response = c.get_domain_cache_full_url('test-sdk.sys-qa.com')
        print(response)

    设置自定义错误码页面

    def test_set_domain_error_page(c):
        """
        test set domain error page
        """
        error_page = [
                        {'code': 404, 'redirectCode':302, 'url': '/customer_404.html'},
                        {'code': 403, 'url': '/customer_403.html'}
                     ]
        domain = 'test-sdk.sys-qa.com'
        response = c.set_domain_error_page(domain, error_page);
        print(response)

    查询自定义错误码页面

    def test_get_domain_error_page(c):
        """
        test get domain error page
        """
        response = c.get_domain_error_page('test-sdk.sys-qa.com')
        print(response)
    上一篇
    加速域名管理
    下一篇
    回源配置