Repository: trafficserver
Updated Branches:
  refs/heads/master 4c6f0aeb8 -> 88fc99a47


TS-2632 Do not lock the object in cache (by default) on Range requests


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/88fc99a4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/88fc99a4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/88fc99a4

Branch: refs/heads/master
Commit: 88fc99a47ef551e08c2dea1491016e89fd013324
Parents: 4c6f0ae
Author: Leif Hedstrom <[email protected]>
Authored: Tue May 20 21:33:20 2014 -0600
Committer: Leif Hedstrom <[email protected]>
Committed: Wed May 21 13:44:49 2014 -0600

----------------------------------------------------------------------
 doc/arch/cache/cache-arch.en.rst                  | 10 +++++++++-
 doc/reference/api/TSHttpOverridableConfig.en.rst  |  1 +
 doc/reference/configuration/records.config.en.rst |  8 ++++++++
 lib/perl/lib/Apache/TS/AdminClient.pm             |  1 +
 lib/ts/apidefs.h.in                               |  1 +
 mgmt/RecordsConfig.cc                             |  2 ++
 proxy/InkAPI.cc                                   | 16 +++++++++++++---
 proxy/InkAPITest.cc                               |  3 ++-
 proxy/http/HttpConfig.cc                          |  2 ++
 proxy/http/HttpConfig.h                           |  4 +++-
 proxy/http/HttpTransact.cc                        | 11 ++++++-----
 11 files changed, 48 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/doc/arch/cache/cache-arch.en.rst
----------------------------------------------------------------------
diff --git a/doc/arch/cache/cache-arch.en.rst b/doc/arch/cache/cache-arch.en.rst
index 3989e52..8990d7d 100644
--- a/doc/arch/cache/cache-arch.en.rst
+++ b/doc/arch/cache/cache-arch.en.rst
@@ -551,7 +551,15 @@ The checks that are done are
       In addition if a TTL is set for rule that matches in 
:file:`cache.config` then this check is not done.
 
    Range Request
-      Cache valid only if :ts:cv:`proxy.config.http.cache.range.lookup` in 
:file:`records.config` is non-zero. This does not mean the range request can be 
cached, only that it might be satisfiable from the cache.
+      Cache valid only if :ts:cv:`proxy.config.http.cache.range.lookup` in
+      :file:`records.config` is non-zero. This does not mean the range request
+           can be cached, only that it might be satisfiable from the
+           cache. In addition, :ts:cv:`proxy.config.http.cache.range.write`
+           can be set to try to force a write on a range request. This
+           probably has little value at the moment, but if for example the
+           origin server ignores the ``Range:`` header, this option can allow
+           for the response to be cached. It is disabled by default, for
+           best performance.
 
 A plugin can call :c:func:`TSHttpTxnReqCacheableSet()` to force the request to 
be viewed as cache valid.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/doc/reference/api/TSHttpOverridableConfig.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSHttpOverridableConfig.en.rst 
b/doc/reference/api/TSHttpOverridableConfig.en.rst
index 09f7da8..d6f092c 100644
--- a/doc/reference/api/TSHttpOverridableConfig.en.rst
+++ b/doc/reference/api/TSHttpOverridableConfig.en.rst
@@ -133,6 +133,7 @@ The following configurations (from ``records.config``) are 
overridable: ::
     proxy.config.http.negative_revalidating_enabled
     proxy.config.http.negative_revalidating_lifetime
     proxy.config.http.accept_encoding_filter_enabled
+    proxy.config.http.cache.range.write
 
 
 Examples

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/doc/reference/configuration/records.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/records.config.en.rst 
b/doc/reference/configuration/records.config.en.rst
index 53c6973..a965d27 100644
--- a/doc/reference/configuration/records.config.en.rst
+++ b/doc/reference/configuration/records.config.en.rst
@@ -1168,6 +1168,14 @@ Cache Control
 
    When enabled (``1``), Traffic Server looks up range requests in the cache.
 
+.. ts:cv:: CONFIG proxy.config.http.cache.range.write INT 0
+
+   When enabled (``1``), Traffic Server will attempt to write (lock) the URL
+   to cache. This is rarely useful (at the moment), since it'll only be able
+   to write to cache if the origin has ignored the ``Range:` header. For a use
+   case where you know the origin will respond with a full (``200``) response,
+   you can turn this on to allow it to be cached.
+
 .. ts:cv:: CONFIG proxy.config.http.cache.ignore_accept_mismatch INT 2
    :reloadable:
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/lib/perl/lib/Apache/TS/AdminClient.pm
----------------------------------------------------------------------
diff --git a/lib/perl/lib/Apache/TS/AdminClient.pm 
b/lib/perl/lib/Apache/TS/AdminClient.pm
index edd9683..4c72786 100644
--- a/lib/perl/lib/Apache/TS/AdminClient.pm
+++ b/lib/perl/lib/Apache/TS/AdminClient.pm
@@ -465,6 +465,7 @@ The Apache Traffic Server Administration Manual will 
explain what these strings
  proxy.config.http.cache.max_stale_age
  proxy.config.http.cache.open_read_retry_time
  proxy.config.http.cache.range.lookup
+ proxy.config.http.cache.range.write
  proxy.config.http.cache.required_headers
  proxy.config.http.cache.vary_default_images
  proxy.config.http.cache.vary_default_other

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/lib/ts/apidefs.h.in
----------------------------------------------------------------------
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index eae2b4f..7958c59 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -762,6 +762,7 @@ extern "C"
     TS_CONFIG_SSL_HSTS_INCLUDE_SUBDOMAINS,
     TS_CONFIG_HTTP_CACHE_OPEN_READ_RETRY_TIME,
     TS_CONFIG_HTTP_CACHE_MAX_OPEN_READ_RETRIES,
+    TS_CONFIG_HTTP_CACHE_RANGE_WRITE,
     TS_CONFIG_LAST_ENTRY
   } TSOverridableConfigKey;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index f46a5b8..9b060da 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -663,6 +663,8 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.http.cache.range.lookup", RECD_INT, "1", 
RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
+  {RECT_CONFIG, "proxy.config.http.cache.range.write", RECD_INT, "0", 
RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  ,
 
   //        ########################
   //        # heuristic expiration #

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 95c0218..34845ca 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7855,7 +7855,6 @@ _conf_to_memberp(TSOverridableConfigKey conf,
     ret = &overridableHttpConfig->proxy_response_hsts_max_age;
     break;
   case TS_CONFIG_SSL_HSTS_INCLUDE_SUBDOMAINS:
-    typ = OVERRIDABLE_TYPE_BYTE;
     ret = &overridableHttpConfig->proxy_response_hsts_include_subdomains;
     break;
   case TS_CONFIG_HTTP_CACHE_OPEN_READ_RETRY_TIME:
@@ -7866,6 +7865,9 @@ _conf_to_memberp(TSOverridableConfigKey conf,
     typ = OVERRIDABLE_TYPE_INT;
     ret = &overridableHttpConfig->max_cache_open_read_retries;
     break;
+  case TS_CONFIG_HTTP_CACHE_RANGE_WRITE:
+    ret = &overridableHttpConfig->cache_range_write;
+    break;
 
     // This helps avoiding compiler warnings, yet detect unhandled enum 
members.
   case TS_CONFIG_NULL:
@@ -8109,8 +8111,16 @@ TSHttpTxnConfigFind(const char* name, int length, 
TSOverridableConfigKey *conf,
     break;
 
   case 35:
-    if (!strncmp(name, "proxy.config.http.normalize_ae_gzip", length))
-      cnf = TS_CONFIG_HTTP_NORMALIZE_AE_GZIP;
+    switch (name[length-1]) {
+    case 'e':
+      if (!strncmp(name, "proxy.config.http.cache.range.write", length))
+        cnf = TS_CONFIG_HTTP_CACHE_RANGE_WRITE;
+      break;
+    case 'p':
+      if (!strncmp(name, "proxy.config.http.normalize_ae_gzip", length))
+        cnf = TS_CONFIG_HTTP_NORMALIZE_AE_GZIP;
+      break;
+    }
     break;
 
   case 36:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 5541323..39add2c 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -7418,7 +7418,8 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] 
= {
   "proxy.config.ssl.hsts_max_age",
   "proxy.config.ssl.hsts_include_subdomains",
   "proxy.config.http.cache.open_read_retry_time",
-  "proxy.config.http.cache.max_open_read_retries"
+  "proxy.config.http.cache.max_open_read_retries",
+  "proxy.config.http.cache.range.write",
 };
 
 REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS) (RegressionTest * test, int /* 
atype ATS_UNUSED */, int *pstatus)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/proxy/http/HttpConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 7f8339a..8ea140d 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1428,6 +1428,7 @@ HttpConfig::startup()
                                     
"proxy.config.http.cache.when_to_add_no_cache_to_msie_requests");
   HttpEstablishStaticConfigByte(c.oride.cache_required_headers, 
"proxy.config.http.cache.required_headers");
   HttpEstablishStaticConfigByte(c.oride.cache_range_lookup, 
"proxy.config.http.cache.range.lookup");
+  HttpEstablishStaticConfigByte(c.oride.cache_range_write, 
"proxy.config.http.cache.range.write");
 
   HttpEstablishStaticConfigStringAlloc(c.connect_ports_string, 
"proxy.config.http.connect_ports");
 
@@ -1677,6 +1678,7 @@ HttpConfig::reconfigure()
 
   params->oride.cache_required_headers = m_master.oride.cache_required_headers;
   params->oride.cache_range_lookup = 
INT_TO_BOOL(m_master.oride.cache_range_lookup);
+  params->oride.cache_range_write = 
INT_TO_BOOL(m_master.oride.cache_range_write);
 
   params->connect_ports_string = ats_strdup(m_master.connect_ports_string);
   params->connect_ports = parse_ports_list(params->connect_ports_string);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/proxy/http/HttpConfig.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 3089fd3..cf3c946 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -414,7 +414,8 @@ struct OverridableHttpConfigParams {
       insert_squid_x_forwarded_for(1), send_http11_requests(1),
       cache_http(1), cache_cluster_cache_local(0), 
cache_ignore_client_no_cache(1), cache_ignore_client_cc_max_age(0),
       cache_ims_on_client_no_cache(1), cache_ignore_server_no_cache(0), 
cache_responses_to_cookies(1),
-      cache_ignore_auth(0), cache_urls_that_look_dynamic(1), 
cache_required_headers(2), cache_range_lookup(1),
+      cache_ignore_auth(0), cache_urls_that_look_dynamic(1), 
cache_required_headers(2),
+      cache_range_lookup(1), cache_range_write(0),
       insert_request_via_string(1), insert_response_via_string(0), 
doc_in_cache_skip_dns(1),
       flow_control_enabled(0), accept_encoding_filter_enabled(0), 
normalize_ae_gzip(0),
       negative_caching_lifetime(1800), negative_revalidating_lifetime(1800),
@@ -505,6 +506,7 @@ struct OverridableHttpConfigParams {
   MgmtByte cache_urls_that_look_dynamic;
   MgmtByte cache_required_headers;
   MgmtByte cache_range_lookup;
+  MgmtByte cache_range_write;
 
   MgmtByte insert_request_via_string;
   MgmtByte insert_response_via_string;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88fc99a4/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 4fcee20..3dd9432 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -1853,8 +1853,7 @@ HttpTransact::OSDNSLookup(State* s)
       StartAccessControl(s);    // If skip_dns is enabled and no ip based 
rules in cache.config and parent.config
       // Access Control is called after DNS response
     } else {
-      if ((s->cache_info.action == CACHE_DO_NO_ACTION) &&
-          (s->range_setup == RANGE_NOT_SATISFIABLE || s->range_setup == 
RANGE_NOT_HANDLED)) {
+      if ((s->cache_info.action == CACHE_DO_NO_ACTION) && 
s->hdr_info.client_request.presence(MIME_PRESENCE_RANGE)) {
         TRANSACT_RETURN(SM_ACTION_API_OS_DNS, HandleCacheOpenReadMiss);
       } else if (s->cache_lookup_result == HttpTransact::CACHE_LOOKUP_SKIPPED) 
{
         TRANSACT_RETURN(SM_ACTION_API_OS_DNS, LookupSkipOpenServer);
@@ -3091,7 +3090,7 @@ HttpTransact::HandleCacheOpenReadMiss(State* s)
   // We must, however, not cache the responses to these requests.
   if (does_method_require_cache_copy_deletion(s->method) && 
s->api_req_cacheable == false) {
     s->cache_info.action = CACHE_DO_NO_ACTION;
-  } else if (s->range_setup == RANGE_NOT_SATISFIABLE || s->range_setup == 
RANGE_NOT_HANDLED) {
+  } else if (s->hdr_info.client_request.presence(MIME_PRESENCE_RANGE)) {
     s->cache_info.action = CACHE_DO_NO_ACTION;
   } else {
     s->cache_info.action = CACHE_PREPARE_TO_WRITE;
@@ -6098,7 +6097,7 @@ HttpTransact::is_request_cache_lookupable(State* s)
     }
   }
 
-  // Don't cache if it's a RANGE request but the cache is not enabled for 
RANGE.
+  // Don't look in cache if it's a RANGE request but the cache is not enabled 
for RANGE.
   if (!s->txn_conf->cache_range_lookup && 
s->hdr_info.client_request.presence(MIME_PRESENCE_RANGE)) {
     SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_HEADER_FIELD);
     return false;
@@ -7773,7 +7772,9 @@ HttpTransact::handle_server_died(State* s)
 bool
 HttpTransact::is_request_likely_cacheable(State* s, HTTPHdr* request)
 {
-  if ((s->method == HTTP_WKSIDX_GET || s->api_req_cacheable == true) && 
!request->presence(MIME_PRESENCE_AUTHORIZATION)) {
+  if ((s->method == HTTP_WKSIDX_GET || s->api_req_cacheable == true) &&
+      !request->presence(MIME_PRESENCE_AUTHORIZATION) &&
+      (!request->presence(MIME_PRESENCE_RANGE) || 
s->txn_conf->cache_range_write)) {
     return true;
   }
   return false;

Reply via email to