MythTV master
Static Public Member Functions | List of all members
MythHTTPCache Class Reference

#include <libmythbase/http/mythhttpcache.h>

Static Public Member Functions

static void PreConditionCheck (const HTTPResponse &Response)
 Process precondition checks. More...
 
static void PreConditionHeaders (const HTTPResponse &Response)
 Add precondition (cache) headers to the response. More...
 

Detailed Description

Definition at line 7 of file mythhttpcache.h.

Member Function Documentation

◆ PreConditionCheck()

void MythHTTPCache::PreConditionCheck ( const HTTPResponse Response)
static

Process precondition checks.

This should be the first step in processing an HTTP request, typically only when there is meaningful content to be returned (i.e. it is not used for error responses, even though they may contain content).

The status of the response may be updated and the ETag for the content may be set.

'Last-Modified' and 'ETag' outgoing headers are supported, dependant on the cache setting for the content. This defaults to HTTPIgnoreCache for errors etc, HTTPLastModified for files and HTTPNoCache for in-memory data responses. It is expected that the latter will be configured as required by the handler's implementation.

'If-Modified-Since', 'If-None-Match' and 'If-Range' headers are supported in incoming headers (i.e. last modified and ETag validators).

There is currently no suport for 'If-Match' and 'If-Unmodified-Since' headers.

We only ever use one validator and it is assumed the validator is used consistently. i.e. we use ETag or Last-Modified across invocations and not both. This ensures the client sends the correct validator in response.

Note
Last-Modified is used for files as they have valid last modified information, last modified data gives reasonable validation (see below) and hashing the file contents (or in memory data for compressed content) for the ETag is potentially expensive.
Last-Modified is considered a weak validator as it only has second accuracy. This should however be sufficient for our purposes when sending files. Likewise our hashing for file responses when using ETag should also be considered weak (as it does not guarantee byte-for-byte accuracy). Again however it should be considered accurate enough for our needs - and more accurate than Last-Modified as we use millisecond accuracy for our hash generation.
It is recommended that Etags vary depending on the content encoding (e.g. gzipped). We do not currently support this as our decision to compress depends on content size, type, and the client range and encoding requests. It should not however be an issue (!)

Definition at line 50 of file mythhttpcache.cpp.

Referenced by MythHTTPResponse::DataResponse(), and MythHTTPResponse::FileResponse().

◆ PreConditionHeaders()

void MythHTTPCache::PreConditionHeaders ( const HTTPResponse Response)
static

Add precondition (cache) headers to the response.

Must be after a call to PreConditionCheck.

Definition at line 158 of file mythhttpcache.cpp.

Referenced by MythHTTPResponse::DataResponse(), and MythHTTPResponse::FileResponse().


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