站点全局配置接口
更新时间:2026-07-22
设置站点全局配置
您可以根据API文档获取您想要设置的站点全局配置项的详细参数信息。
节点配置
Python
1def test_set_site_config_follow_origin_default(eo_client):
2 """
3 follow origin - default cache policy
4 """
5 response = eo_client.set_site_config(
6 site='test-sdk-eo.baidu.com',
7 cacheTtl=[])
8 print(response)
9
10
11def test_set_site_config_follow_origin_no_cache(eo_client):
12 """
13 follow origin - no cache
14 """
15 response = eo_client.set_site_config(
16 site='test-sdk-eo.baidu.com',
17 cacheTtl=[{
18 'value': '/',
19 'weight': 100,
20 'override_origin': False,
21 'ttl': 0,
22 'type': 'path'
23 }])
24 print(response)
查询字符串
Python
1def test_set_site_cache_key_keep_all(eo_client):
2 """
3 keep all query string
4 """
5 response = eo_client.set_site_cache_key(
6 site='test-sdk-eo.baidu.com',
7 cacheKey={'query': True})
8 print(response)
9
10
11def test_set_site_cache_key_ignore_all(eo_client):
12 """
13 ignore all query string
14 """
15 response = eo_client.set_site_cache_key(
16 site='test-sdk-eo.baidu.com',
17 cacheKey={'query': False, 'include_args': []})
18 print(response)
19
20
21def test_set_site_cache_key_include_args(eo_client):
22 """
23 keep the specified query args
24 """
25 response = eo_client.set_site_cache_key(
26 site='test-sdk-eo.baidu.com',
27 cacheKey={'query': False, 'include_args': ['test1']})
28 print(response)
29
30
31def test_set_site_cache_key_exclude_args(eo_client):
32 """
33 ignore the specified query args
34 """
35 response = eo_client.set_site_cache_key(
36 site='test-sdk-eo.baidu.com',
37 cacheKey={'query': False, 'exclude_args': ['test1', 'test2']})
38 print(response)
离线模式
Python
1def test_set_site_offline_mode_on(eo_client):
2 """
3 enable offline mode
4 """
5 response = eo_client.set_site_offline_mode(
6 site='test-sdk-eo.baidu.com',
7 offlineMode='ON')
8 print(response)
强制HTTPS
Python
1def test_set_site_https_redirect_302(eo_client):
2 """
3 enable force https redirect with 302
4 """
5 response = eo_client.set_site_https_redirect(
6 site='test-sdk-eo.baidu.com',
7 httpToHttpsEnabled='ON',
8 httpToHttpsCode='302')
9 print(response)
10
11
12def test_set_site_https_redirect_301(eo_client):
13 """
14 enable force https redirect with 301
15 """
16 response = eo_client.set_site_https_redirect(
17 site='test-sdk-eo.baidu.com',
18 httpToHttpsEnabled='ON',
19 httpToHttpsCode='301')
20 print(response)
21
22
23def test_set_site_https_redirect_off(eo_client):
24 """
25 disable force https redirect
26 """
27 response = eo_client.set_site_https_redirect(
28 site='test-sdk-eo.baidu.com',
29 httpToHttpsEnabled='OFF')
30 print(response)
HSTS
Python
1def test_set_site_hsts_off(eo_client):
2 """
3 disable hsts
4 """
5 response = eo_client.set_site_hsts(
6 site='test-sdk-eo.baidu.com',
7 hsts={'maxAge': -1, 'includeSubDomains': False, 'preload': False})
8 print(response)
9
10
11def test_set_site_hsts_on(eo_client):
12 """
13 enable hsts
14 """
15 response = eo_client.set_site_hsts(
16 site='test-sdk-eo.baidu.com',
17 hsts={'includeSubDomains': True, 'preload': False, 'maxAge': 60})
18 print(response)
HTTP2
Python
1def test_set_site_http2_disable(eo_client):
2 """
3 disable http2
4 """
5 response = eo_client.set_site_http2_disable(
6 site='test-sdk-eo.baidu.com',
7 http2Disable='ON')
8 print(response)
HTTP3
Python
1def test_set_site_http3_on(eo_client):
2 """
3 enable http3
4 """
5 response = eo_client.set_site_http3(
6 site='test-sdk-eo.baidu.com',
7 http3={'enable': True})
8 print(response)
9
10
11def test_set_site_http3_off(eo_client):
12 """
13 disable http3
14 """
15 response = eo_client.set_site_http3(
16 site='test-sdk-eo.baidu.com',
17 http3={'enable': False})
18 print(response)
最大上传大小
Python
1def test_set_site_client_max_body_size(eo_client):
2 """
3 set the max upload body size config
4 """
5 response = eo_client.set_site_client_max_body_size(
6 site='test-sdk-eo.baidu.com',
7 clientMaxBodySize='500m')
8 print(response)
页面压缩
Python
1def test_set_site_compress_on(eo_client):
2 """
3 enable page compress
4 """
5 response = eo_client.set_site_compress(
6 site='test-sdk-eo.baidu.com',
7 compress='ON',
8 compressMethodArray=['gzip', 'br'])
9 print(response)
10
11
12def test_set_site_compress_off(eo_client):
13 """
14 disable page compress
15 """
16 response = eo_client.set_site_compress(
17 site='test-sdk-eo.baidu.com',
18 compress='OFF',
19 compressMethodArray=[])
20 print(response)
智能加速
Python
1def test_set_site_isa_on(eo_client):
2 """
3 enable intelligent acceleration
4 """
5 response = eo_client.set_site_isa(
6 site='test-sdk-eo.baidu.com',
7 isa='ON')
8 print(response)
9
10
11def test_set_site_isa_off(eo_client):
12 """
13 disable intelligent acceleration
14 """
15 response = eo_client.set_site_isa(
16 site='test-sdk-eo.baidu.com',
17 isa='OFF')
18 print(response)
HTTP节点响应头和回源请求头
Python
1def test_set_site_http_header_set(eo_client):
2 """
3 set http header
4 """
5 response = eo_client.set_site_http_header(
6 site='test-sdk-eo.baidu.com',
7 httpHeader=[
8 {'type': 'response', 'header': 'Cache-Control', 'value': 'test', 'action': 'add'},
9 {'action': 'add', 'type': 'origin', 'header': 'Expires', 'value': 'test'}
10 ])
11 print(response)
12
13
14def test_set_site_http_header_remove(eo_client):
15 """
16 remove http header
17 """
18 response = eo_client.set_site_http_header(
19 site='test-sdk-eo.baidu.com',
20 httpHeader=[
21 {'type': 'response', 'value': '', 'action': 'remove', 'header': 'Expires'},
22 {'value': '', 'type': 'origin', 'action': 'remove', 'header': 'Cache-Control'}
23 ])
24 print(response)
状态码缓存
Python
1def test_set_site_cache_code_ttl(eo_client):
2 """
3 set the status code cache config
4 """
5 response = eo_client.set_site_cache_code_ttl(
6 site='test-sdk-eo.baidu.com',
7 cacheCodeTtl=[
8 {'value': '404', 'weight': 100, 'overrideOrigin': True, 'ttl': 10, 'type': 'code'},
9 {'value': '400', 'weight': 100, 'overrideOrigin': True, 'ttl': 10, 'type': 'code'}
10 ])
11 print(response)
gRpc回源
Python
1def test_set_site_grpc_origin_on(eo_client):
2 """
3 enable grpc origin
4 """
5 response = eo_client.set_site_grpc_origin(
6 site='test-sdk-eo.baidu.com',
7 grpcOrigin='ON')
8 print(response)
9
10
11def test_set_site_grpc_origin_off(eo_client):
12 """
13 disable grpc origin
14 """
15 response = eo_client.set_site_grpc_origin(
16 site='test-sdk-eo.baidu.com',
17 grpcOrigin='OFF')
18 print(response)
HTTP2回源
Python
1def test_set_site_http2_origin_on(eo_client):
2 """
3 enable http2 origin
4 """
5 response = eo_client.set_site_http2_origin(
6 site='test-sdk-eo.baidu.com',
7 http2Origin='ON')
8 print(response)
9
10
11def test_set_site_http2_origin_off(eo_client):
12 """
13 disable http2 origin
14 """
15 response = eo_client.set_site_http2_origin(
16 site='test-sdk-eo.baidu.com',
17 http2Origin='OFF')
18 print(response)
评价此篇文章
