TS-1255 Add negative revalidation as overridable configs, and cleanup
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ec65b119 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ec65b119 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ec65b119 Branch: refs/heads/3.3.x Commit: ec65b1193fcb9bcd6ee2150160c94d6825a85a25 Parents: b0e7c2a Author: Leif Hedstrom <[email protected]> Authored: Sun Jul 28 23:59:53 2013 +0200 Committer: Leif Hedstrom <[email protected]> Committed: Thu Aug 1 22:42:49 2013 +0200 ---------------------------------------------------------------------- .../configuration/records.config.en.rst | 3 +++ proxy/InkAPI.cc | 14 +++++++++++++ proxy/InkAPITest.cc | 4 +++- proxy/api/ts/ts.h.in | 2 ++ proxy/http/HttpConfig.cc | 15 ++++++------- proxy/http/HttpConfig.h | 22 +++++++++----------- proxy/http/HttpTransact.cc | 4 ++-- 7 files changed, 40 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec65b119/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 a17fbbd..3b0d1e2 100644 --- a/doc/reference/configuration/records.config.en.rst +++ b/doc/reference/configuration/records.config.en.rst @@ -764,6 +764,9 @@ Negative Response Caching 503 Service Unavailable 504 Gateway Timeout + The cache lifetime for objects cached from this setting is controlled via + ``proxy.config.http.negative_caching_lifetime``. + Proxy User Variables ==================== http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec65b119/proxy/InkAPI.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 99c833d..63001f2 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -7585,6 +7585,14 @@ _conf_to_memberp(TSOverridableConfigKey conf, HttpSM* sm, OverridableDataType *t typ = OVERRIDABLE_TYPE_INT; ret = &sm->t_state.txn_conf->response_hdr_max_size; break; + case TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_ENABLED: + typ = OVERRIDABLE_TYPE_INT; + ret = &sm->t_state.txn_conf->negative_revalidating_enabled; + break; + case TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_LIFETIME: + typ = OVERRIDABLE_TYPE_INT; + ret = &sm->t_state.txn_conf->negative_revalidating_lifetime; + break; // This helps avoiding compiler warnings, yet detect unhandled enum members. case TS_CONFIG_NULL: @@ -8025,6 +8033,10 @@ TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey *conf, case 47: switch (name[length-1]) { + case 'd': + if (!strncmp(name, "proxy.config.http.negative_revalidating_enabled", length)) + cnf = TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_ENABLED; + break; case 'e': if (!strncmp(name, "proxy.config.http.cache.guaranteed_min_lifetime", length)) cnf = TS_CONFIG_HTTP_CACHE_GUARANTEED_MIN_LIFETIME; @@ -8043,6 +8055,8 @@ TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey *conf, case 'e': if (!strncmp(name, "proxy.config.http.cache.ignore_client_cc_max_age", length)) cnf = TS_CONFIG_HTTP_CACHE_IGNORE_CLIENT_CC_MAX_AGE; + else if (!strncmp(name, "proxy.config.http.negative_revalidating_lifetime", length)) + cnf = TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_LIFETIME; break; case 't': switch (name[length-4]) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec65b119/proxy/InkAPITest.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc index 85cc589..108a125 100644 --- a/proxy/InkAPITest.cc +++ b/proxy/InkAPITest.cc @@ -7401,7 +7401,9 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = { "proxy.config.http.default_buffer_size", "proxy.config.http.default_buffer_water_mark", "proxy.config.http.request_header_max_size", - "proxy.config.http.response_header_max_size" + "proxy.config.http.response_header_max_size", + "proxy.config.http.negative_revalidating_enabled", + "proxy.config.http.negative_revalidating_lifetime" }; REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS) (RegressionTest * test, int /* atype ATS_UNUSED */, int *pstatus) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec65b119/proxy/api/ts/ts.h.in ---------------------------------------------------------------------- diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in index 47eeaf6..4b34bd8 100644 --- a/proxy/api/ts/ts.h.in +++ b/proxy/api/ts/ts.h.in @@ -677,6 +677,8 @@ extern "C" TS_CONFIG_HTTP_DEFAULT_BUFFER_WATER_MARK, TS_CONFIG_HTTP_REQUEST_HEADER_MAX_SIZE, TS_CONFIG_HTTP_RESPONSE_HEADER_MAX_SIZE, + TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_ENABLED, + TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_LIFETIME, TS_CONFIG_LAST_ENTRY } TSOverridableConfigKey; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec65b119/proxy/http/HttpConfig.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index c8c0abc..1f7c478 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -1316,17 +1316,15 @@ HttpConfig::startup() HttpEstablishStaticConfigByte(c.referer_filter_enabled, "proxy.config.http.referer_filter"); HttpEstablishStaticConfigByte(c.referer_format_redirect, "proxy.config.http.referer_format_redirect"); - // Negative caching HttpEstablishStaticConfigLongLong(c.oride.down_server_timeout, "proxy.config.http.down_server.cache_time"); HttpEstablishStaticConfigLongLong(c.oride.client_abort_threshold, "proxy.config.http.down_server.abort_threshold"); - // Negative revalidating - HttpEstablishStaticConfigByte(c.negative_revalidating_enabled, "proxy.config.http.negative_revalidating_enabled"); - HttpEstablishStaticConfigLongLong(c.negative_revalidating_lifetime, "proxy.config.http.negative_revalidating_lifetime"); - - // Negative response caching + // Negative caching and revalidation HttpEstablishStaticConfigByte(c.oride.negative_caching_enabled, "proxy.config.http.negative_caching_enabled"); HttpEstablishStaticConfigLongLong(c.oride.negative_caching_lifetime, "proxy.config.http.negative_caching_lifetime"); + HttpEstablishStaticConfigByte(c.oride.negative_revalidating_enabled, "proxy.config.http.negative_revalidating_enabled"); + HttpEstablishStaticConfigLongLong(c.oride.negative_revalidating_lifetime, + "proxy.config.http.negative_revalidating_lifetime"); // Buffer size and watermark HttpEstablishStaticConfigLongLong(c.oride.default_buffer_size_index, "proxy.config.http.default_buffer_size"); @@ -1588,11 +1586,10 @@ params->push_method_enabled = INT_TO_BOOL(m_master.push_method_enabled); params->oride.down_server_timeout = m_master.oride.down_server_timeout; params->oride.client_abort_threshold = m_master.oride.client_abort_threshold; - params->negative_revalidating_enabled = INT_TO_BOOL(m_master.negative_revalidating_enabled); - params->negative_revalidating_lifetime = m_master.negative_revalidating_lifetime; - params->oride.negative_caching_enabled = INT_TO_BOOL(m_master.oride.negative_caching_enabled); params->oride.negative_caching_lifetime = m_master.oride.negative_caching_lifetime; + params->oride.negative_revalidating_enabled = INT_TO_BOOL(m_master.oride.negative_revalidating_enabled); + params->oride.negative_revalidating_lifetime = m_master.oride.negative_revalidating_lifetime; //############################################################################## //# http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec65b119/proxy/http/HttpConfig.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index de47b94..d4970e5 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -401,7 +401,7 @@ struct HttpConfigPortRange struct OverridableHttpConfigParams { OverridableHttpConfigParams() : maintain_pristine_host_hdr(1), chunking_enabled(1), - negative_caching_enabled(0), cache_when_to_revalidate(0), + negative_caching_enabled(0), negative_revalidating_enabled(0), cache_when_to_revalidate(0), keep_alive_enabled_in(1), keep_alive_enabled_out(1), keep_alive_post_out(0), share_server_sessions(2), fwd_proxy_auth_to_parent(0), insert_age_in_response(1), anonymize_remove_from(0), anonymize_remove_referer(0), anonymize_remove_user_agent(0), @@ -411,7 +411,8 @@ struct OverridableHttpConfigParams { 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), insert_request_via_string(1), insert_response_via_string(0), doc_in_cache_skip_dns(1), - negative_caching_lifetime(1800), normalize_ae_gzip(0), + flow_control_enabled(0), accept_encoding_filter_enabled(0), normalize_ae_gzip(0), + negative_caching_lifetime(1800), negative_revalidating_lifetime(1800), sock_recv_buffer_size_out(0), sock_send_buffer_size_out(0), sock_option_flag_out(0), sock_packet_mark_out(0), sock_packet_tos_out(0), server_tcp_init_cwnd(0), request_hdr_max_size(131072), response_hdr_max_size(131072), @@ -446,6 +447,7 @@ struct OverridableHttpConfigParams { // Negative Response Caching // //////////////////////////////// MgmtByte negative_caching_enabled; + MgmtByte negative_revalidating_enabled; MgmtByte cache_when_to_revalidate; @@ -504,13 +506,17 @@ struct OverridableHttpConfigParams { MgmtByte doc_in_cache_skip_dns; MgmtByte flow_control_enabled; - MgmtInt negative_caching_lifetime; - //////////////////////////////// // Optimize gzip alternates // //////////////////////////////// MgmtByte normalize_ae_gzip; + //////////////////////////////// + // Negative cache lifetimes // + //////////////////////////////// + MgmtInt negative_caching_lifetime; + MgmtInt negative_revalidating_lifetime; + /////////////////////////////////////// // origin server connection settings // /////////////////////////////////////// @@ -741,12 +747,6 @@ public: char *reverse_proxy_no_host_redirect; int reverse_proxy_no_host_redirect_len; - //////////////////////////// - // Negative Revalidating // - //////////////////////////// - MgmtByte negative_revalidating_enabled; - MgmtInt negative_revalidating_lifetime; - /////////////////// // cop access // /////////////////// @@ -932,8 +932,6 @@ HttpConfigParams::HttpConfigParams() server_transparency_enabled(false), reverse_proxy_enabled(0), url_remap_required(1), - negative_revalidating_enabled(0), - negative_revalidating_lifetime(1800), record_cop_page(0), record_tcp_mem_hit(0), errors_log_error_pages(1), http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec65b119/proxy/http/HttpTransact.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index 23696ae..a39447e 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -4103,14 +4103,14 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State* s) server_response_code == HTTP_STATUS_BAD_GATEWAY || server_response_code == HTTP_STATUS_SERVICE_UNAVAILABLE) && s->cache_info.action == CACHE_DO_UPDATE && - s->http_config_param->negative_revalidating_enabled && is_stale_cache_response_returnable(s)) { + s->txn_conf->negative_revalidating_enabled && is_stale_cache_response_returnable(s)) { DebugTxn("http_trans", "[hcoofsr] negative revalidating: revalidate stale object and serve from cache"); s->cache_info.object_store.create(); s->cache_info.object_store.request_set(&s->hdr_info.client_request); s->cache_info.object_store.response_set(s->cache_info.object_read->response_get()); base_response = s->cache_info.object_store.response_get(); - time_t exp_time = s->http_config_param->negative_revalidating_lifetime + ink_cluster_time(); + time_t exp_time = s->txn_conf->negative_revalidating_lifetime + ink_cluster_time(); base_response->set_expires(exp_time); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_UPDATED);
