Apache HTTPD
Functions | Variables
mod_cache.c File Reference
#include "mod_cache.h"
#include "cache_storage.h"
#include "cache_util.h"

Go to the source code of this file.

Functions

static int cache_quick_handler (request_rec *r, int lookup)
 
static int cache_replace_filter (ap_filter_t *next, ap_filter_rec_t *from, ap_filter_rec_t *to, ap_filter_rec_t *stop)
 
static ap_filter_tcache_get_filter (ap_filter_t *next, ap_filter_rec_t *rec)
 
static int cache_handler (request_rec *r)
 
static apr_status_t cache_out_filter (ap_filter_t *f, apr_bucket_brigade *in)
 
static int cache_save_store (ap_filter_t *f, apr_bucket_brigade *in, cache_server_conf *conf, cache_request_rec *cache)
 
static int cache_header_cmp (apr_pool_t *pool, apr_table_t *left, apr_table_t *right, const char *key)
 
static apr_status_t cache_save_filter (ap_filter_t *f, apr_bucket_brigade *in)
 
static apr_status_t cache_remove_url_filter (ap_filter_t *f, apr_bucket_brigade *in)
 
static apr_status_t cache_invalidate_filter (ap_filter_t *f, apr_bucket_brigade *in)
 
static apr_status_t cache_filter (ap_filter_t *f, apr_bucket_brigade *in)
 
static int cache_status (cache_handle_t *h, request_rec *r, apr_table_t *headers, ap_cache_status_e status, const char *reason)
 
static void cache_insert_error_filter (request_rec *r)
 
static void * create_dir_config (apr_pool_t *p, char *dummy)
 
static void * merge_dir_config (apr_pool_t *p, void *basev, void *addv)
 
static void * create_cache_config (apr_pool_t *p, server_rec *s)
 
static void * merge_cache_config (apr_pool_t *p, void *basev, void *overridesv)
 
static const charset_cache_quick_handler (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_ignore_no_last_mod (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_ignore_cachecontrol (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_store_expired (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_store_private (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_store_nostore (cmd_parms *parms, void *dummy, int flag)
 
static const charadd_ignore_header (cmd_parms *parms, void *dummy, const char *header)
 
static const charadd_ignore_session_id (cmd_parms *parms, void *dummy, const char *identifier)
 
static const charadd_cache_enable (cmd_parms *parms, void *dummy, const char *type, const char *url)
 
static const charadd_cache_disable (cmd_parms *parms, void *dummy, const char *url)
 
static const charset_cache_maxex (cmd_parms *parms, void *dummy, const char *arg)
 
static const charset_cache_minex (cmd_parms *parms, void *dummy, const char *arg)
 
static const charset_cache_defex (cmd_parms *parms, void *dummy, const char *arg)
 
static const charset_cache_factor (cmd_parms *parms, void *dummy, const char *arg)
 
static const charset_cache_ignore_querystring (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_lock (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_lock_path (cmd_parms *parms, void *dummy, const char *arg)
 
static const charset_cache_lock_maxage (cmd_parms *parms, void *dummy, const char *arg)
 
static const charset_cache_x_cache (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_x_cache_detail (cmd_parms *parms, void *dummy, int flag)
 
static const charset_cache_key_base_url (cmd_parms *parms, void *dummy, const char *arg)
 
static const charset_cache_stale_on_error (cmd_parms *parms, void *dummy, int flag)
 
static int cache_post_config (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 
static void register_hooks (apr_pool_t *p)
 
void cache_hook_cache_status (cache_HOOK_cache_status_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
 
apr_array_header_tcache_hook_get_cache_status (void)
 
int cache_run_cache_status (cache_handle_t *h, request_rec *r, apr_table_t *headers, ap_cache_status_e status, const char *reason)
 

Variables

apr_OFN_ap_cache_generate_key_tcache_generate_key
 
static ap_filter_rec_tcache_filter_handle
 
static ap_filter_rec_tcache_save_filter_handle
 
static ap_filter_rec_tcache_save_subreq_filter_handle
 
static ap_filter_rec_tcache_out_filter_handle
 
static ap_filter_rec_tcache_out_subreq_filter_handle
 
static ap_filter_rec_tcache_remove_url_filter_handle
 
static ap_filter_rec_tcache_invalidate_filter_handle
 
static const charMOD_CACHE_ENTITY_HEADERS []
 
static const command_rec cache_cmds []
 
static int *const aplog_module_index = &( cache_module.module_index)
 
struct { 
 
   apr_array_header_t *   link_cache_status 
 
_hooks 
 

Function Documentation

◆ add_cache_disable()

static const char * add_cache_disable ( cmd_parms parms,
void *  dummy,
const char url 
)
static

< Forbidden in <Directory>

< Forbidden in <Limit>

< Forbidden in <Files> or <If>

Definition at line 2286 of file mod_cache.c.

◆ add_cache_enable()

static const char * add_cache_enable ( cmd_parms parms,
void *  dummy,
const char type,
const char url 
)
static

< Forbidden in <Directory>

< Forbidden in <Limit>

< Forbidden in <Files> or <If>

Definition at line 2229 of file mod_cache.c.

◆ add_ignore_header()

static const char * add_ignore_header ( cmd_parms parms,
void *  dummy,
const char header 
)
static

Definition at line 2173 of file mod_cache.c.

◆ add_ignore_session_id()

static const char * add_ignore_session_id ( cmd_parms parms,
void *  dummy,
const char identifier 
)
static

Definition at line 2201 of file mod_cache.c.

◆ cache_filter()

static apr_status_t cache_filter ( ap_filter_t f,
apr_bucket_brigade in 
)
static

Definition at line 1735 of file mod_cache.c.

◆ cache_get_filter()

static ap_filter_t * cache_get_filter ( ap_filter_t next,
ap_filter_rec_t rec 
)
static

Find the given filter, and return it if found, or NULL otherwise.

Definition at line 377 of file mod_cache.c.

◆ cache_handler()

static int cache_handler ( request_rec r)
static

The cache handler is functionally similar to the cache_quick_hander, however a number of steps that are required by the quick handler are not required here, as the normal httpd processing has already handled these steps.

< Module declines to handle

< Module declines to handle

< Module declines to handle

< Module declines to handle

RFC 2616: HTTP

< Module declines to handle

< Module has handled this stage.

< Module declines to handle

< Module declines to handle

< Module has handled this stage.

Definition at line 393 of file mod_cache.c.

◆ cache_header_cmp()

static int cache_header_cmp ( apr_pool_t pool,
apr_table_t left,
apr_table_t right,
const char key 
)
static

Sanity check for 304 Not Modified responses, as per RFC2616 Section 10.3.5.

Definition at line 777 of file mod_cache.c.

◆ cache_insert_error_filter()

static void cache_insert_error_filter ( request_rec r)
static

If an error has occurred, but we have a stale cached entry, restore the filter stack from the save filter onwards. The canned error message will be discarded in the process, and replaced with the cached response.

Definition at line 1841 of file mod_cache.c.

◆ cache_invalidate_filter()

static apr_status_t cache_invalidate_filter ( ap_filter_t f,
apr_bucket_brigade in 
)
static

Definition at line 1670 of file mod_cache.c.

◆ cache_out_filter()

static apr_status_t cache_out_filter ( ap_filter_t f,
apr_bucket_brigade in 
)
static

Definition at line 641 of file mod_cache.c.

◆ cache_post_config()

static int cache_post_config ( apr_pool_t p,
apr_pool_t plog,
apr_pool_t ptemp,
server_rec s 
)
static

< Module has handled this stage.

Definition at line 2515 of file mod_cache.c.

◆ cache_quick_handler()

static int cache_quick_handler ( request_rec r,
int  lookup 
)
static

< Module declines to handle

< Module declines to handle

< Module declines to handle

< Module declines to handle

< Module declines to handle

RFC 2616: HTTP

< Module declines to handle

< Module has handled this stage.

< Module declines to handle

< Module declines to handle

< Module has handled this stage.

< Module declines to handle

< Module has handled this stage.

Definition at line 83 of file mod_cache.c.

◆ cache_remove_url_filter()

static apr_status_t cache_remove_url_filter ( ap_filter_t f,
apr_bucket_brigade in 
)
static

Definition at line 1625 of file mod_cache.c.

◆ cache_replace_filter()

static int cache_replace_filter ( ap_filter_t next,
ap_filter_rec_t from,
ap_filter_rec_t to,
ap_filter_rec_t stop 
)
static

If the two filter handles are present within the filter chain, replace the last instance of the first filter with the last instance of the second filter, and return true. If the second filter is not present at all, the first filter is removed, and false is returned. If neither filter is present, false is returned and this function does nothing. If a stop filter is specified, processing will stop once this filter is reached.

Definition at line 350 of file mod_cache.c.

◆ cache_save_filter()

static apr_status_t cache_save_filter ( ap_filter_t f,
apr_bucket_brigade in 
)
static

< Module has handled this stage.

13.12 Cache Replacement:

Note: a new response that has an older Date header value than existing cached responses is not cacheable.

Enforce RFC2616 Section 10.3.5, just in case. We caught any inconsistencies above.

If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

Definition at line 809 of file mod_cache.c.

◆ cache_save_store()

static int cache_save_store ( ap_filter_t f,
apr_bucket_brigade in,
cache_server_conf conf,
cache_request_rec cache 
)
static

Definition at line 702 of file mod_cache.c.

◆ cache_status()

static int cache_status ( cache_handle_t h,
request_rec r,
apr_table_t headers,
ap_cache_status_e  status,
const char reason 
)
static

If configured, add the status of the caching attempt to the subprocess environment, and if configured, to headers in the response.

The status is saved below the broad category of the status (hit, miss, revalidate), as well as a single cache-status key. This can be used for conditional logging.

The status is optionally saved to an X-Cache header, and the detail of why a particular cache entry was cached (or not cached) is optionally saved to an X-Cache-Detail header. This extra detail is useful for service developers who may need to know whether their Cache-Control headers are working correctly.

< Module has handled this stage.

Definition at line 1776 of file mod_cache.c.

◆ create_cache_config()

static void * create_cache_config ( apr_pool_t p,
server_rec s 
)
static

Definition at line 2008 of file mod_cache.c.

◆ create_dir_config()

static void * create_dir_config ( apr_pool_t p,
char dummy 
)
static

Definition at line 1929 of file mod_cache.c.

◆ merge_cache_config()

static void * merge_cache_config ( apr_pool_t p,
void *  basev,
void *  overridesv 
)
static

Definition at line 2043 of file mod_cache.c.

◆ merge_dir_config()

static void * merge_dir_config ( apr_pool_t p,
void *  basev,
void *  addv 
)
static

Definition at line 1958 of file mod_cache.c.

◆ register_hooks()

static void register_hooks ( apr_pool_t p)
static

Definition at line 2605 of file mod_cache.c.

◆ set_cache_defex()

static const char * set_cache_defex ( cmd_parms parms,
void *  dummy,
const char arg 
)
static

Definition at line 2351 of file mod_cache.c.

◆ set_cache_factor()

static const char * set_cache_factor ( cmd_parms parms,
void *  dummy,
const char arg 
)
static

Definition at line 2361 of file mod_cache.c.

◆ set_cache_ignore_cachecontrol()

static const char * set_cache_ignore_cachecontrol ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2130 of file mod_cache.c.

◆ set_cache_ignore_no_last_mod()

static const char * set_cache_ignore_no_last_mod ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2119 of file mod_cache.c.

◆ set_cache_ignore_querystring()

static const char * set_cache_ignore_querystring ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2375 of file mod_cache.c.

◆ set_cache_key_base_url()

static const char * set_cache_key_base_url ( cmd_parms parms,
void *  dummy,
const char arg 
)
static

Definition at line 2483 of file mod_cache.c.

◆ set_cache_lock()

static const char * set_cache_lock ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2388 of file mod_cache.c.

◆ set_cache_lock_maxage()

static const char * set_cache_lock_maxage ( cmd_parms parms,
void *  dummy,
const char arg 
)
static

Definition at line 2419 of file mod_cache.c.

◆ set_cache_lock_path()

static const char * set_cache_lock_path ( cmd_parms parms,
void *  dummy,
const char arg 
)
static

Definition at line 2401 of file mod_cache.c.

◆ set_cache_maxex()

static const char * set_cache_maxex ( cmd_parms parms,
void *  dummy,
const char arg 
)
static

Definition at line 2331 of file mod_cache.c.

◆ set_cache_minex()

static const char * set_cache_minex ( cmd_parms parms,
void *  dummy,
const char arg 
)
static

Definition at line 2341 of file mod_cache.c.

◆ set_cache_quick_handler()

static const char * set_cache_quick_handler ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2105 of file mod_cache.c.

◆ set_cache_stale_on_error()

static const char * set_cache_stale_on_error ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2505 of file mod_cache.c.

◆ set_cache_store_expired()

static const char * set_cache_store_expired ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2143 of file mod_cache.c.

◆ set_cache_store_nostore()

static const char * set_cache_store_nostore ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2163 of file mod_cache.c.

◆ set_cache_store_private()

static const char * set_cache_store_private ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2153 of file mod_cache.c.

◆ set_cache_x_cache()

static const char * set_cache_x_cache ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2437 of file mod_cache.c.

◆ set_cache_x_cache_detail()

static const char * set_cache_x_cache_detail ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 2460 of file mod_cache.c.

Variable Documentation

◆ [struct]

struct { ... } _hooks

◆ aplog_module_index

int* const aplog_module_index = &( cache_module.module_index)
static

Definition at line 2698 of file mod_cache.c.

◆ cache_cmds

const command_rec cache_cmds[]
static

Definition at line 2529 of file mod_cache.c.

◆ cache_filter_handle

ap_filter_rec_t* cache_filter_handle
static

Definition at line 31 of file mod_cache.c.

◆ cache_generate_key

apr_OFN_ap_cache_generate_key_t* cache_generate_key

Definition at line 23 of file mod_cache.c.

◆ cache_invalidate_filter_handle

ap_filter_rec_t* cache_invalidate_filter_handle
static

Definition at line 37 of file mod_cache.c.

◆ cache_out_filter_handle

ap_filter_rec_t* cache_out_filter_handle
static

Definition at line 34 of file mod_cache.c.

◆ cache_out_subreq_filter_handle

ap_filter_rec_t* cache_out_subreq_filter_handle
static

Definition at line 35 of file mod_cache.c.

◆ cache_remove_url_filter_handle

ap_filter_rec_t* cache_remove_url_filter_handle
static

Definition at line 36 of file mod_cache.c.

◆ cache_save_filter_handle

ap_filter_rec_t* cache_save_filter_handle
static

Definition at line 32 of file mod_cache.c.

◆ cache_save_subreq_filter_handle

ap_filter_rec_t* cache_save_subreq_filter_handle
static

Definition at line 33 of file mod_cache.c.

◆ link_cache_status

apr_array_header_t* link_cache_status

Definition at line 2711 of file mod_cache.c.

◆ MOD_CACHE_ENTITY_HEADERS

const char* MOD_CACHE_ENTITY_HEADERS[]
static
Initial value:
= {
"Allow",
"Content-Encoding",
"Content-Language",
"Content-Length",
"Content-Location",
"Content-MD5",
"Content-Range",
"Content-Type",
"Last-Modified",
}
return NULL
Definition mod_so.c:359

Entity headers' names

Definition at line 42 of file mod_cache.c.