This is an automated email from the ASF dual-hosted git repository.
oknet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 14143b7 Cache:ttl-in-cache should always override never-cache
14143b7 is described below
commit 14143b7c4c77817eddd313f7c46c8924cff3c270
Author: yangjian <[email protected]>
AuthorDate: Thu Mar 28 16:00:43 2019 +0800
Cache:ttl-in-cache should always override never-cache
---
doc/admin-guide/files/cache.config.en.rst | 13 ++++++++++++-
proxy/CacheControl.cc | 9 ++++++---
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/doc/admin-guide/files/cache.config.en.rst
b/doc/admin-guide/files/cache.config.en.rst
index 40d3a05..3971b9a 100644
--- a/doc/admin-guide/files/cache.config.en.rst
+++ b/doc/admin-guide/files/cache.config.en.rst
@@ -157,7 +157,8 @@ specifiers of the rule in question.
=========================== ================================================
Value Effect
=========================== ================================================
- ``never-cache`` Never cache specified objects.
+ ``never-cache`` Never cache specified objects, it will be
+ overwrited by ``ttl-in-cache``.
``ignore-no-cache`` Ignore all ``Cache-Control: no-cache`` headers.
``ignore-client-no-cache`` Ignore ``Cache-Control: no-cache`` headers from
client requests.
@@ -250,6 +251,16 @@ prefix. The former fails at this goal, because the second
rule will match all
Javascript files and will override any previous ``revalidate`` values that may
have been set by prior rules.
+ttl-in-cache and never-cache
+----------------------------
+
+When multiple rules are matched in the same request, ``never-cache`` will
always
+be overwrited by ``ttl-in-cache``. For example::
+
+ # ttl-in-cache=1d never-cache=false
+ dest_domain=example.com action=never-cache
+ dest_domain=example.com ttl-in-cache=1d
+
Examples
========
diff --git a/proxy/CacheControl.cc b/proxy/CacheControl.cc
index 6e78ed0..423584e 100644
--- a/proxy/CacheControl.cc
+++ b/proxy/CacheControl.cc
@@ -372,9 +372,12 @@ CacheControlRecord::UpdateMatch(CacheControlResult
*result, RequestData *rdata)
break;
case CC_NEVER_CACHE:
if (this->CheckForMatch(h_rdata, result->never_line) == true) {
- result->never_cache = true;
- result->never_line = this->line_num;
- match = true;
+ // ttl-in-cache overrides never-cache
+ if (result->ttl_line == -1) {
+ result->never_cache = true;
+ result->never_line = this->line_num;
+ match = true;
+ }
}
break;
case CC_STANDARD_CACHE: