Static Public Member Functions

HttpTransactCache Class Reference

#include <HttpTransactCache.h>

Static Public Member Functions

static int SelectFromAlternates (CacheHTTPInfoVector *cache_vector_data, HTTPHdr *client_request, CacheLookupHttpConfig *cache_lookup_http_config_params)
 Given a set of alternates, select the best match.
static float calculate_quality_of_match (CacheLookupHttpConfig *http_config_params, HTTPHdr *client_request, HTTPHdr *obj_client_request, HTTPHdr *obj_origin_server_response)
 For cached req/res and incoming req, return quality of match.
static float calculate_quality_of_accept_match (MIMEField *accept_field, MIMEField *content_field)
static float calculate_quality_of_accept_charset_match (MIMEField *accept_field, MIMEField *content_field, MIMEField *cached_accept_field=NULL)
static float calculate_quality_of_accept_encoding_match (MIMEField *accept_field, MIMEField *content_field, MIMEField *cached_accept_field=NULL)
static ContentEncoding match_gzip (MIMEField *accept_field)
static float calculate_quality_of_accept_language_match (MIMEField *accept_field, MIMEField *content_field, MIMEField *cached_accept_field=NULL)
static Variability_t CalcVariability (CacheLookupHttpConfig *http_config_params, HTTPHdr *client_request, HTTPHdr *obj_client_request, HTTPHdr *obj_origin_server_response)
 If the cached object contains a Vary header, then the object only matches if ALL of the headers named in Vary are present in the new request, and these match the headers in the stored request.
static HTTPStatus match_response_to_request_conditionals (HTTPHdr *ua_request, HTTPHdr *c_response)
 If the request has If-modified-since or If-none-match, HTTP_STATUS_NOT_MODIFIED is returned if both or the existing one (if only one exists) fails; otherwise, the response's status code is returned.

Detailed Description

Definition at line 100 of file HttpTransactCache.h.


Member Function Documentation

float HttpTransactCache::calculate_quality_of_accept_charset_match ( MIMEField accept_field,
MIMEField content_field,
MIMEField cached_accept_field = NULL 
) [static]
float HttpTransactCache::calculate_quality_of_accept_encoding_match ( MIMEField accept_field,
MIMEField content_field,
MIMEField cached_accept_field = NULL 
) [static]
float HttpTransactCache::calculate_quality_of_accept_language_match ( MIMEField accept_field,
MIMEField content_field,
MIMEField cached_accept_field = NULL 
) [static]
float HttpTransactCache::calculate_quality_of_accept_match ( MIMEField accept_field,
MIMEField content_field 
) [static]
float HttpTransactCache::calculate_quality_of_match ( CacheLookupHttpConfig http_config_param,
HTTPHdr client_request,
HTTPHdr obj_client_request,
HTTPHdr obj_origin_server_response 
) [static]

For cached req/res and incoming req, return quality of match.

The current school of thought: quality 1st, freshness 2nd. This function takes a user agent request client_request and the two headers for a cached object (obj_client_request and obj_origin_server_response), and returns a floating point number for how well the object matches the client's request.

Two factors currently affect a match: Accept headers, which filter and sort the matches, and Vary headers, which constrain whether a dynamic document matches a request.

Note: According to the specs, specific matching takes precedence over wildcard matching. For example, listed in precedence: text/html;q=0.5, text/ascii, image/'*', '*'/'*'. So, ideally, in choosing between alternates, we should given preference to those which matched specifically over those which matched with wildcards.

Returns:
quality (-1: no match, 0..1: poor..good).

Definition at line 299 of file HttpTransactCache.cc.

References calculate_quality_of_accept_charset_match(), calculate_quality_of_accept_encoding_match(), calculate_quality_of_accept_language_match(), calculate_quality_of_accept_match(), CalcVariability(), HTTPHdr::clear(), HTTPHdr::copy_shallow(), Debug, MIMEHdr::field_find(), FeatureAPIHooks< ID, N >::get(), http_global_hooks, HTTP_WKSIDX_PURGE, CacheLookupHttpConfig::ignore_accept_charset_mismatch, CacheLookupHttpConfig::ignore_accept_encoding_mismatch, CacheLookupHttpConfig::ignore_accept_language_mismatch, CacheLookupHttpConfig::ignore_accept_mismatch, APIHook::invoke(), HttpAltInfo::m_cached_req, HttpAltInfo::m_cached_resp, HttpAltInfo::m_client_req, HttpAltInfo::m_qvalue, HTTPHdr::method_get_wksidx(), MIME_FIELD_ACCEPT, MIME_FIELD_ACCEPT_CHARSET, MIME_FIELD_ACCEPT_ENCODING, MIME_FIELD_ACCEPT_LANGUAGE, MIME_FIELD_CONTENT_ENCODING, MIME_FIELD_CONTENT_LANGUAGE, MIME_FIELD_CONTENT_TYPE, MIME_LEN_ACCEPT, MIME_LEN_ACCEPT_CHARSET, MIME_LEN_ACCEPT_ENCODING, MIME_LEN_ACCEPT_LANGUAGE, MIME_LEN_CONTENT_ENCODING, MIME_LEN_CONTENT_LANGUAGE, MIME_LEN_CONTENT_TYPE, MIME_PRESENCE_VARY, APIHook::next(), MIMEHdr::presence(), TS_EVENT_HTTP_SELECT_ALT, TS_HTTP_SELECT_ALT_HOOK, and VARIABILITY_NONE.

Referenced by SelectFromAlternates().

Variability_t HttpTransactCache::CalcVariability ( CacheLookupHttpConfig http_config_params,
HTTPHdr client_request,
HTTPHdr obj_client_request,
HTTPHdr obj_origin_server_response 
) [static]
ContentEncoding HttpTransactCache::match_gzip ( MIMEField accept_field  )  [static]
HTTPStatus HttpTransactCache::match_response_to_request_conditionals ( HTTPHdr request,
HTTPHdr response 
) [static]

If the request has If-modified-since or If-none-match, HTTP_STATUS_NOT_MODIFIED is returned if both or the existing one (if only one exists) fails; otherwise, the response's status code is returned.

If the request has If-unmodified-since or If-match, HTTP_STATUS_PRECONDITION_FAILED is returned if one fails; otherwise, the response's status code is returned.

If the request is a RANGE request with If-range, HTTP_STATUS_RANGE_NOT_SATISFIABLE is returned if the If-range condition is not satisfied (or fails); that means the document is changed and the whole document should be returned with 200 status code. Otherwise, the response's status code is returned.

Returns:
status code: HTTP_STATUS_NOT_MODIFIED, HTTP_STATUS_PRECONDITION_FAILED, or HTTP_STATUS_RANGE_NOT_SATISFIABLE.

Definition at line 1310 of file HttpTransactCache.cc.

References do_strings_match_strongly(), do_strings_match_weakly(), MIMEHdr::get_if_modified_since(), MIMEHdr::get_if_range_date(), MIMEHdr::get_if_unmodified_since(), MIMEHdr::get_last_modified(), HTTP_STATUS_NONE, ink_assert, MIME_FIELD_ETAG, MIME_FIELD_IF_MATCH, MIME_FIELD_IF_NONE_MATCH, MIME_FIELD_IF_RANGE, MIME_LEN_ETAG, MIME_LEN_IF_MATCH, MIME_LEN_IF_NONE_MATCH, MIME_LEN_IF_RANGE, MIME_PRESENCE_IF_MATCH, MIME_PRESENCE_IF_MODIFIED_SINCE, MIME_PRESENCE_IF_NONE_MATCH, MIME_PRESENCE_IF_RANGE, MIME_PRESENCE_IF_UNMODIFIED_SINCE, MIME_PRESENCE_RANGE, MIMEHdr::presence(), HTTPHdr::status_get(), and MIMEHdr::value_get().

Referenced by HttpTransact::build_response_from_cache(), and HttpTransact::handle_cache_operation_on_forward_server_response().

int HttpTransactCache::SelectFromAlternates ( CacheHTTPInfoVector cache_vector,
HTTPHdr client_request,
CacheLookupHttpConfig http_config_params 
) [static]

Given a set of alternates, select the best match.

The current school of thought: quality 1st, freshness 2nd. Loop through alternates and find the one with the highest quality factor. Then determine if it is fresh enough. If not, find the next best match. In keeping with "quality is job 1", subsequent matches will only be considered if their quality is equal to the quality of the first match.

Returns:
index in cache alternates vector.

Definition at line 168 of file HttpTransactCache.cc.

References ACQUIRE_PRINT_LOCK, HttpTransactHeaders::calculate_document_age(), calculate_quality_of_match(), CacheHTTPInfoVector::count(), Debug, diags, CacheHTTPInfoVector::get(), MIMEHdr::get_date(), ink_assert, ink_cluster_time(), Diags::on(), HTTPHdr::print(), RELEASE_PRINT_LOCK, HTTPHdr::valid(), and zero_key.

Referenced by CacheVC::openReadChooseWriter(), and CacheVC::openReadStartHead().


The documentation for this class was generated from the following files: