Apache HTTPD
Classes | Macros | Typedefs | Functions
Cache Utility Functions

Classes

struct  cache_enable
 
struct  cache_disable
 
struct  cache_server_conf
 
struct  cache_dir_conf
 
struct  cache_provider_list
 
struct  cache_request_rec
 

Macros

#define APR_WANT_STRFUNC
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define MSEC_ONE_DAY   ((apr_time_t)(86400*APR_USEC_PER_SEC)) /* one day, in microseconds */
 
#define MSEC_ONE_HR   ((apr_time_t)(3600*APR_USEC_PER_SEC)) /* one hour, in microseconds */
 
#define MSEC_ONE_MIN   ((apr_time_t)(60*APR_USEC_PER_SEC)) /* one minute, in microseconds */
 
#define MSEC_ONE_SEC   ((apr_time_t)(APR_USEC_PER_SEC)) /* one second, in microseconds */
 
#define DEFAULT_CACHE_MAXEXPIRE   MSEC_ONE_DAY
 
#define DEFAULT_CACHE_MINEXPIRE   0
 
#define DEFAULT_CACHE_EXPIRE   MSEC_ONE_HR
 
#define DEFAULT_CACHE_LMFACTOR   (0.1)
 
#define DEFAULT_CACHE_MAXAGE   5
 
#define DEFAULT_X_CACHE   0
 
#define DEFAULT_X_CACHE_DETAIL   0
 
#define DEFAULT_CACHE_STALE_ON_ERROR   1
 
#define DEFAULT_CACHE_LOCKPATH   "/mod_cache-lock"
 
#define CACHE_LOCKNAME_KEY   "mod_cache-lockname"
 
#define CACHE_LOCKFILE_KEY   "mod_cache-lockfile"
 
#define CACHE_CTX_KEY   "mod_cache-ctx"
 
#define CACHE_SEPARATOR   ", \t"
 

Typedefs

typedef struct cache_provider_list cache_provider_list
 

Functions

int ap_cache_check_no_cache (cache_request_rec *cache, request_rec *r)
 
int ap_cache_check_no_store (cache_request_rec *cache, request_rec *r)
 
int cache_check_freshness (cache_handle_t *h, cache_request_rec *cache, request_rec *r)
 
apr_status_t cache_try_lock (cache_server_conf *conf, cache_request_rec *cache, request_rec *r)
 
apr_status_t cache_remove_lock (cache_server_conf *conf, cache_request_rec *cache, request_rec *r, apr_bucket_brigade *bb)
 
cache_provider_listcache_get_providers (request_rec *r, cache_server_conf *conf)
 
const charcache_table_getm (apr_pool_t *p, const apr_table_t *t, const char *key)
 
charcache_strqtok (char *str, const char *sep, char **last)
 
apr_table_tcache_merge_headers_out (request_rec *r)
 
int cache_use_early_url (request_rec *r)
 

Detailed Description

Macro Definition Documentation

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 44 of file cache_util.h.

◆ CACHE_CTX_KEY

#define CACHE_CTX_KEY   "mod_cache-ctx"

Definition at line 101 of file cache_util.h.

◆ CACHE_LOCKFILE_KEY

#define CACHE_LOCKFILE_KEY   "mod_cache-lockfile"

Definition at line 100 of file cache_util.h.

◆ CACHE_LOCKNAME_KEY

#define CACHE_LOCKNAME_KEY   "mod_cache-lockname"

Definition at line 99 of file cache_util.h.

◆ CACHE_SEPARATOR

#define CACHE_SEPARATOR   ", \t"

Definition at line 102 of file cache_util.h.

◆ DEFAULT_CACHE_EXPIRE

#define DEFAULT_CACHE_EXPIRE   MSEC_ONE_HR

Definition at line 92 of file cache_util.h.

◆ DEFAULT_CACHE_LMFACTOR

#define DEFAULT_CACHE_LMFACTOR   (0.1)

Definition at line 93 of file cache_util.h.

◆ DEFAULT_CACHE_LOCKPATH

#define DEFAULT_CACHE_LOCKPATH   "/mod_cache-lock"

Definition at line 98 of file cache_util.h.

◆ DEFAULT_CACHE_MAXAGE

#define DEFAULT_CACHE_MAXAGE   5

Definition at line 94 of file cache_util.h.

◆ DEFAULT_CACHE_MAXEXPIRE

#define DEFAULT_CACHE_MAXEXPIRE   MSEC_ONE_DAY

Definition at line 90 of file cache_util.h.

◆ DEFAULT_CACHE_MINEXPIRE

#define DEFAULT_CACHE_MINEXPIRE   0

Definition at line 91 of file cache_util.h.

◆ DEFAULT_CACHE_STALE_ON_ERROR

#define DEFAULT_CACHE_STALE_ON_ERROR   1

Definition at line 97 of file cache_util.h.

◆ DEFAULT_X_CACHE

#define DEFAULT_X_CACHE   0

Definition at line 95 of file cache_util.h.

◆ DEFAULT_X_CACHE_DETAIL

#define DEFAULT_X_CACHE_DETAIL   0

Definition at line 96 of file cache_util.h.

◆ MAX

#define MAX (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 79 of file cache_util.h.

◆ MIN

#define MIN (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 82 of file cache_util.h.

◆ MSEC_ONE_DAY

#define MSEC_ONE_DAY   ((apr_time_t)(86400*APR_USEC_PER_SEC)) /* one day, in microseconds */

Definition at line 85 of file cache_util.h.

◆ MSEC_ONE_HR

#define MSEC_ONE_HR   ((apr_time_t)(3600*APR_USEC_PER_SEC)) /* one hour, in microseconds */

Definition at line 86 of file cache_util.h.

◆ MSEC_ONE_MIN

#define MSEC_ONE_MIN   ((apr_time_t)(60*APR_USEC_PER_SEC)) /* one minute, in microseconds */

Definition at line 87 of file cache_util.h.

◆ MSEC_ONE_SEC

#define MSEC_ONE_SEC   ((apr_time_t)(APR_USEC_PER_SEC)) /* one second, in microseconds */

Definition at line 88 of file cache_util.h.

Typedef Documentation

◆ cache_provider_list

Definition at line 201 of file cache_util.h.

Function Documentation

◆ ap_cache_check_no_cache()

int ap_cache_check_no_cache ( cache_request_rec cache,
request_rec r 
)

Check the whether the request allows a cached object to be served as per RFC2616 section 14.9.4 (Cache Revalidation and Reload Controls)

Parameters
cachecache_request_rec
rrequest_rec
Returns
0 ==> cache object may not be served, 1 ==> cache object may be served

Definition at line 450 of file cache_util.c.

◆ ap_cache_check_no_store()

int ap_cache_check_no_store ( cache_request_rec cache,
request_rec r 
)

Check the whether the request allows a cached object to be stored as per RFC2616 section 14.9.2 (What May be Stored by Caches)

Parameters
cachecache_request_rec
rrequest_rec
Returns
0 ==> cache object may not be served, 1 ==> cache object may be served

Definition at line 493 of file cache_util.c.

◆ cache_check_freshness()

int cache_check_freshness ( cache_handle_t h,
cache_request_rec cache,
request_rec r 
)

Check the freshness of the cache object per RFC2616 section 13.2 (Expiration Model)

Parameters
hcache_handle_t
cachecache_request_rec
rrequest_rec
Returns
0 ==> cache object is stale, 1 ==> cache object is fresh

Definition at line 533 of file cache_util.c.

◆ cache_get_providers()

cache_provider_list * cache_get_providers ( request_rec r,
cache_server_conf conf 
)

Definition at line 184 of file cache_util.c.

◆ cache_merge_headers_out()

apr_table_t * cache_merge_headers_out ( request_rec r)

Merge err_headers_out into headers_out and add request's Content-Type and Content-Encoding if available.

Definition at line 1267 of file cache_util.c.

◆ cache_remove_lock()

apr_status_t cache_remove_lock ( cache_server_conf conf,
cache_request_rec cache,
request_rec r,
apr_bucket_brigade bb 
)

Remove the cache lock, if present.

First, try to close the file handle, whose delete-on-close should kill the file. Otherwise, just delete the file by name.

If no lock name has yet been calculated, do the calculation of the lock name first before trying to delete the file.

If an optional bucket brigade is passed, the lock will only be removed if the bucket brigade contains an EOS bucket.

Definition at line 390 of file cache_util.c.

◆ cache_strqtok()

char * cache_strqtok ( char str,
const char sep,
char **  last 
)

String tokenizer that ignores separator characters within quoted strings and escaped characters, as per RFC2616 section 2.2.

Definition at line 929 of file cache_util.c.

◆ cache_table_getm()

const char * cache_table_getm ( apr_pool_t p,
const apr_table_t t,
const char key 
)

Get a value from a table, where the table may contain multiple values for a given key.

When the table contains a single value, that value is returned unchanged.

When the table contains two or more values for a key, all values for the key are returned, separated by commas.

Definition at line 1324 of file cache_util.c.

◆ cache_try_lock()

apr_status_t cache_try_lock ( cache_server_conf conf,
cache_request_rec cache,
request_rec r 
)

Try obtain a cache wide lock on the given cache key.

If we return APR_SUCCESS, we obtained the lock, and we are clear to proceed to the backend. If we return APR_EEXISTS, then the lock is already locked, someone else has gone to refresh the backend data already, so we must return stale data with a warning in the mean time. If we return anything else, then something has gone pear shaped, and we allow the request through to the backend regardless.

This lock is created from the request pool, meaning that should something go wrong and the lock isn't deleted on return of the request headers from the backend for whatever reason, at worst the lock will be cleaned up when the request is dies or finishes.

If something goes truly bananas and the lock isn't deleted when the request dies, the lock will be trashed when its max-age is reached, or when a request arrives containing a Cache-Control: no-cache. At no point is it possible for this lock to permanently deny access to the backend.

Try obtain a cache wide lock on the given cache key.

If we return APR_SUCCESS, we obtained the lock, and we are clear to proceed to the backend. If we return APR_EEXIST, then the lock is already locked, someone else has gone to refresh the backend data already, so we must return stale data with a warning in the mean time. If we return anything else, then something has gone pear shaped, and we allow the request through to the backend regardless.

This lock is created from the request pool, meaning that should something go wrong and the lock isn't deleted on return of the request headers from the backend for whatever reason, at worst the lock will be cleaned up when the request dies or finishes.

If something goes truly bananas and the lock isn't deleted when the request dies, the lock will be trashed when its max-age is reached, or when a request arrives containing a Cache-Control: no-cache. At no point is it possible for this lock to permanently deny access to the backend.

< Read by user

<

Deprecated:
See also
APR_FPROT_UREAD

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Modification Time

< Number of links

< Open the file for writing

<

Deprecated:
See also
APR_FOPEN_WRITE

< Create the file if not there

<

Deprecated:
See also
APR_FOPEN_CREATE

< Open should fail if APR_FOPEN_CREATE and file exists.

<

Deprecated:
See also
APR_FOPEN_EXCL

< Delete the file after close

<

Deprecated:
See also
APR_FOPEN_DELONCLOSE

< Read by user

<

Deprecated:
See also
APR_FPROT_UREAD

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

Definition at line 279 of file cache_util.c.

◆ cache_use_early_url()

int cache_use_early_url ( request_rec r)

Return whether to use request's path/query from early stage (r->parsed_uri) or the current/rewritable ones (r->uri/r->args).

< Standard proxy

Definition at line 130 of file cache_util.c.