feat: akamai driver cache setting on zero TTL
- When a caching ttl of zero is set, we do not cache anything on the edge server. We instead set ttl cache type to be `no-store` where a response is never cached, and if any prior policy has allowed objects to be cached, this setting will evict the corresponding cache entry. Change-Id: I8b8da3202285f5ae94a960d5bf878cf267cbbea6
This commit is contained in:
parent
3d19474cf0
commit
0c475c246e
|
@ -609,13 +609,23 @@ class ServiceController(base.ServiceBase):
|
||||||
# we found an existing matching rule.
|
# we found an existing matching rule.
|
||||||
# add the cache behavior to it
|
# add the cache behavior to it
|
||||||
found_match = True
|
found_match = True
|
||||||
rule['behaviors'].append({
|
if caching_rule.ttl == 0:
|
||||||
'name': 'caching',
|
# NOTE(TheSriram): if ttl is set zero,
|
||||||
'type': 'fixed',
|
# we directly serve content from origin and do
|
||||||
# assuming the input number to caching rule
|
# not cache the content on edge server.
|
||||||
# ttl is in second
|
rule['behaviors'].append({
|
||||||
'value': '%ss' % caching_rule.ttl
|
'name': 'caching',
|
||||||
})
|
'type': 'no-store',
|
||||||
|
'value': '%ss' % caching_rule.ttl
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
rule['behaviors'].append({
|
||||||
|
'name': 'caching',
|
||||||
|
'type': 'fixed',
|
||||||
|
# assuming the input number to caching rule
|
||||||
|
# ttl is in second
|
||||||
|
'value': '%ss' % caching_rule.ttl
|
||||||
|
})
|
||||||
|
|
||||||
# if there is no matches entry yet for this rule
|
# if there is no matches entry yet for this rule
|
||||||
if not found_match:
|
if not found_match:
|
||||||
|
@ -632,13 +642,23 @@ class ServiceController(base.ServiceBase):
|
||||||
}
|
}
|
||||||
|
|
||||||
rule_dict_template['matches'].append(match_rule)
|
rule_dict_template['matches'].append(match_rule)
|
||||||
rule_dict_template['behaviors'].append({
|
if caching_rule.ttl == 0:
|
||||||
'name': 'caching',
|
# NOTE(TheSriram): if ttl is set zero,
|
||||||
'type': 'fixed',
|
# we directly serve content from origin and do
|
||||||
# assuming the input number to caching rule
|
# not cache the content on edge server.
|
||||||
# ttl is in second
|
rule_dict_template['behaviors'].append({
|
||||||
'value': '%ss' % caching_rule.ttl
|
'name': 'caching',
|
||||||
})
|
'type': 'no-store',
|
||||||
|
'value': '%ss' % caching_rule.ttl
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
rule_dict_template['behaviors'].append({
|
||||||
|
'name': 'caching',
|
||||||
|
'type': 'fixed',
|
||||||
|
# assuming the input number to caching rule
|
||||||
|
# ttl is in second
|
||||||
|
'value': '%ss' % caching_rule.ttl
|
||||||
|
})
|
||||||
rules_list.append(rule_dict_template)
|
rules_list.append(rule_dict_template)
|
||||||
# end loop - caching_rule.rules
|
# end loop - caching_rule.rules
|
||||||
# end loop - caching_rules
|
# end loop - caching_rules
|
||||||
|
|
|
@ -138,6 +138,45 @@
|
||||||
"rules": [{"name" : "Rule 1",
|
"rules": [{"name" : "Rule 1",
|
||||||
"request_url" : "/images/test.jpg"}]}]
|
"request_url" : "/images/test.jpg"}]}]
|
||||||
},
|
},
|
||||||
|
"multiple_origin_path_multiple_caching_types": {
|
||||||
|
"name": "my_service_name",
|
||||||
|
"domain_list": [{"domain": "mywebsite.com", "protocol": "http"}],
|
||||||
|
"origin_list": [{
|
||||||
|
"origin": "mywebsite1.com",
|
||||||
|
"port": 80,
|
||||||
|
"ssl": false,
|
||||||
|
"rules":[
|
||||||
|
{
|
||||||
|
"name": "default rule",
|
||||||
|
"request_url": "/*"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hostheadertype": "custom",
|
||||||
|
"hostheadervalue": "www.customweb.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": "mywebsite2.com",
|
||||||
|
"port": 80,
|
||||||
|
"ssl": false,
|
||||||
|
"rules":[
|
||||||
|
{
|
||||||
|
"name": "images rules",
|
||||||
|
"request_url": "/images/test.jpg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hostheadertype": "custom",
|
||||||
|
"hostheadervalue": "www.customweb.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"caching_list": [{"name": "default",
|
||||||
|
"ttl": 1200,
|
||||||
|
"rules": [{"name" : "Rule 1",
|
||||||
|
"request_url" : "/images/test.jpg"}]},
|
||||||
|
{"name": "no-store",
|
||||||
|
"ttl": 0,
|
||||||
|
"rules": [{"name" : "Rule 2",
|
||||||
|
"request_url" : "/news/latestnews.html"}]}]
|
||||||
|
},
|
||||||
"log_delivery_enabled": {
|
"log_delivery_enabled": {
|
||||||
"name": "my_service_name",
|
"name": "my_service_name",
|
||||||
"domain_list": [{"domain": "mywebsite.com", "protocol": "http"},
|
"domain_list": [{"domain": "mywebsite.com", "protocol": "http"},
|
||||||
|
|
|
@ -166,6 +166,11 @@
|
||||||
"path": "/caching/0",
|
"path": "/caching/0",
|
||||||
"value": {"name": "cache_name", "ttl": 111, "rules": [{"name" : "index","request_url" : "new_path"}]}}
|
"value": {"name": "cache_name", "ttl": 111, "rules": [{"name" : "index","request_url" : "new_path"}]}}
|
||||||
],
|
],
|
||||||
|
"replace_caching_with_zero_ttl": [
|
||||||
|
{"op": "replace",
|
||||||
|
"path": "/caching/0",
|
||||||
|
"value": {"name": "dynamic_cache", "ttl": 0, "rules": [{"name" : "dynamic","request_url" : "/latest_news/*"}]}}
|
||||||
|
],
|
||||||
"remove_caching": [
|
"remove_caching": [
|
||||||
{"op": "remove",
|
{"op": "remove",
|
||||||
"path": "/caching/0"}
|
"path": "/caching/0"}
|
||||||
|
@ -181,6 +186,12 @@
|
||||||
"value": {"name": "cache_name2", "ttl": 121,
|
"value": {"name": "cache_name2", "ttl": 121,
|
||||||
"rules": [{"name" : "index2",
|
"rules": [{"name" : "index2",
|
||||||
"request_url" : "/index2.htm"}]}
|
"request_url" : "/index2.htm"}]}
|
||||||
|
},
|
||||||
|
{"op": "add",
|
||||||
|
"path": "/caching/-",
|
||||||
|
"value": {"name": "cache_name3", "ttl": 0,
|
||||||
|
"rules": [{"name" : "index3",
|
||||||
|
"request_url" : "/index3.htm"}]}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"add_restrictions": [
|
"add_restrictions": [
|
||||||
|
|
|
@ -53,7 +53,7 @@ origin = {
|
||||||
cache = {'type': 'object',
|
cache = {'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
'name': {'type': 'string'},
|
'name': {'type': 'string'},
|
||||||
'ttl': {'type': 'number', 'minimum': 1, 'maximum': 3600},
|
'ttl': {'type': 'number', 'minimum': 0, 'maximum': 3600},
|
||||||
'rules': {'type': 'array'}},
|
'rules': {'type': 'array'}},
|
||||||
'required': ['name', 'ttl'],
|
'required': ['name', 'ttl'],
|
||||||
'additionalProperties': False}
|
'additionalProperties': False}
|
||||||
|
|
|
@ -90,7 +90,19 @@
|
||||||
"request_url": "/*.gif"
|
"request_url": "/*.gif"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
{"name": "zero-cache", "ttl": 0 },
|
||||||
|
{"name": "dynamic-content",
|
||||||
|
"ttl": 0,
|
||||||
|
"rules": [
|
||||||
|
{ "name": "dynamic-jpeg-rules",
|
||||||
|
"request_url": "/*.jpeg"
|
||||||
|
},
|
||||||
|
{ "name": "dynamic-gif-rules",
|
||||||
|
"request_url": "/*.gif"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"flavor_id" : "standard"
|
"flavor_id" : "standard"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue