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:
Sriram Madapusi Vasudevan 2015-07-16 11:01:13 -04:00
parent 3d19474cf0
commit 0c475c246e
5 changed files with 98 additions and 16 deletions

View File

@ -609,13 +609,23 @@ class ServiceController(base.ServiceBase):
# we found an existing matching rule.
# add the cache behavior to it
found_match = True
rule['behaviors'].append({
'name': 'caching',
'type': 'fixed',
# assuming the input number to caching rule
# ttl is in second
'value': '%ss' % caching_rule.ttl
})
if caching_rule.ttl == 0:
# NOTE(TheSriram): if ttl is set zero,
# we directly serve content from origin and do
# not cache the content on edge server.
rule['behaviors'].append({
'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 not found_match:
@ -632,13 +642,23 @@ class ServiceController(base.ServiceBase):
}
rule_dict_template['matches'].append(match_rule)
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
})
if caching_rule.ttl == 0:
# NOTE(TheSriram): if ttl is set zero,
# we directly serve content from origin and do
# not cache the content on edge server.
rule_dict_template['behaviors'].append({
'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)
# end loop - caching_rule.rules
# end loop - caching_rules

View File

@ -138,6 +138,45 @@
"rules": [{"name" : "Rule 1",
"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": {
"name": "my_service_name",
"domain_list": [{"domain": "mywebsite.com", "protocol": "http"},

View File

@ -166,6 +166,11 @@
"path": "/caching/0",
"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": [
{"op": "remove",
"path": "/caching/0"}
@ -181,6 +186,12 @@
"value": {"name": "cache_name2", "ttl": 121,
"rules": [{"name" : "index2",
"request_url" : "/index2.htm"}]}
},
{"op": "add",
"path": "/caching/-",
"value": {"name": "cache_name3", "ttl": 0,
"rules": [{"name" : "index3",
"request_url" : "/index3.htm"}]}
}
],
"add_restrictions": [

View File

@ -53,7 +53,7 @@ origin = {
cache = {'type': 'object',
'properties': {
'name': {'type': 'string'},
'ttl': {'type': 'number', 'minimum': 1, 'maximum': 3600},
'ttl': {'type': 'number', 'minimum': 0, 'maximum': 3600},
'rules': {'type': 'array'}},
'required': ['name', 'ttl'],
'additionalProperties': False}

View File

@ -90,7 +90,19 @@
"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"
},