mod_cache.h revision 6dafbe869f4b41302bf981039e1294edd5eaf422
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* Licensed to the Apache Software Foundation (ASF) under one or more
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * contributor license agreements. See the NOTICE file distributed with
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * this work for additional information regarding copyright ownership.
0a05fab9aadd37834734ffe106fc8ad4488fb3e3rbowen * The ASF licenses this file to You under the Apache License, Version 2.0
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * (the "License"); you may not use this file except in compliance with
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * the License. You may obtain a copy of the License at
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor *
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * http://www.apache.org/licenses/LICENSE-2.0
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor *
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * Unless required by applicable law or agreed to in writing, software
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * distributed under the License is distributed on an "AS IS" BASIS,
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * See the License for the specific language governing permissions and
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * limitations under the License.
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/**
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * @file mod_cache.h
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * @brief Main include file for the Apache Transparent Cache
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor *
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * @defgroup MOD_CACHE mod_cache
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * @ingroup APACHE_MODS
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * @{
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#ifndef MOD_CACHE_H
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define MOD_CACHE_H
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_hooks.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_lib.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_strings.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_buckets.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_md5.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_pools.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_strings.h"
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis#include "apr_optional.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define APR_WANT_STRFUNC
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_want.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis#include "httpd.h"
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis#include "http_config.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "ap_config.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "http_core.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "http_protocol.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "http_request.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "http_vhost.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "http_main.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "http_log.h"
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#include "http_connection.h"
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#include "util_filter.h"
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#include "apr_date.h"
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#include "apr_uri.h"
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#ifdef HAVE_NETDB_H
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#include <netdb.h>
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#endif
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#ifdef HAVE_SYS_SOCKET_H
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#include <sys/socket.h>
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#endif
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#ifdef HAVE_NETINET_IN_H
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#include <netinet/in.h>
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis#endif
66a40356a2baa1bdc3f91e91399a8bf3d2dbe7c6lgentis
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#ifdef HAVE_ARPA_INET_H
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include <arpa/inet.h>
576c49cd335618ad4b5351bd1c5f2cfd7584dba4lgentis#endif
576c49cd335618ad4b5351bd1c5f2cfd7584dba4lgentis
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include "apr_atomic.h"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#ifndef MAX
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define MAX(a,b) ((a) > (b) ? (a) : (b))
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#endif
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#ifndef MIN
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define MIN(a,b) ((a) < (b) ? (a) : (b))
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#endif
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define MSEC_ONE_DAY ((apr_time_t)(86400*APR_USEC_PER_SEC)) /* one day, in microseconds */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define MSEC_ONE_HR ((apr_time_t)(3600*APR_USEC_PER_SEC)) /* one hour, in microseconds */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define MSEC_ONE_MIN ((apr_time_t)(60*APR_USEC_PER_SEC)) /* one minute, in microseconds */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define MSEC_ONE_SEC ((apr_time_t)(APR_USEC_PER_SEC)) /* one second, in microseconds */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define DEFAULT_CACHE_MAXEXPIRE MSEC_ONE_DAY
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define DEFAULT_CACHE_MINEXPIRE 0
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define DEFAULT_CACHE_EXPIRE MSEC_ONE_HR
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define DEFAULT_CACHE_LMFACTOR (0.1)
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* Create a set of CACHE_DECLARE(type), CACHE_DECLARE_NONSTD(type) and
d89089206f40f9a6d58528ff85050447d4a52d53lgentis * CACHE_DECLARE_DATA with appropriate export and import tags for the platform
d89089206f40f9a6d58528ff85050447d4a52d53lgentis */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#if !defined(WIN32)
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#define CACHE_DECLARE(type) type
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE_NONSTD(type) type
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE_DATA
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#elif defined(CACHE_DECLARE_STATIC)
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#define CACHE_DECLARE(type) type __stdcall
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#define CACHE_DECLARE_NONSTD(type) type
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#define CACHE_DECLARE_DATA
d89089206f40f9a6d58528ff85050447d4a52d53lgentis#elif defined(CACHE_DECLARE_EXPORT)
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE(type) __declspec(dllexport) type __stdcall
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE_NONSTD(type) __declspec(dllexport) type
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE_DATA __declspec(dllexport)
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#else
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE(type) __declspec(dllimport) type __stdcall
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE_NONSTD(type) __declspec(dllimport) type
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_DECLARE_DATA __declspec(dllimport)
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#endif
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorstruct cache_enable {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_uri_t url;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const char *type;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_size_t pathlen;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor};
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorstruct cache_disable {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_uri_t url;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_size_t pathlen;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor};
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* static information about the local cache */
d89089206f40f9a6d58528ff85050447d4a52d53lgentistypedef struct {
d89089206f40f9a6d58528ff85050447d4a52d53lgentis apr_array_header_t *cacheenable; /* URLs to cache */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis apr_array_header_t *cachedisable; /* URLs not to cache */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis /* Maximum time to keep cached files in msecs */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t maxex;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int maxex_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /* default time to keep cached file in msecs */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t defex;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int defex_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /* factor for estimating expires date */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis double factor;
d89089206f40f9a6d58528ff85050447d4a52d53lgentis int factor_set;
d89089206f40f9a6d58528ff85050447d4a52d53lgentis /** ignore the last-modified header when deciding to cache this request */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis int no_last_mod_ignore_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int no_last_mod_ignore;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** ignore client's requests for uncached responses */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int ignorecachecontrol;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int ignorecachecontrol_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** ignore Cache-Control: private header from server */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int store_private;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int store_private_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** ignore Cache-Control: no-store header from client or server */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int store_nostore;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int store_nostore_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** store the headers that should not be stored in the cache */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_array_header_t *ignore_headers;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /* flag if CacheIgnoreHeader has been set */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor #define CACHE_IGNORE_HEADERS_SET 1
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor #define CACHE_IGNORE_HEADERS_UNSET 0
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int ignore_headers_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /* Minimum time to keep cached files in msecs */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t minex;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int minex_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** ignore query-string when caching */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int ignorequerystring;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int ignorequerystring_set;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor} cache_server_conf;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* cache info information */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzortypedef struct cache_info cache_info;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorstruct cache_info {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /**
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * HTTP status code of the cached entity. Though not neccessarily the
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * status code finally issued to the request.
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int status;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /**
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * the original time corresponding to the 'Date:' header of the request
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * served
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t date;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** a time when the cached entity is due to expire */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t expire;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** r->request_time from the same request */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t request_time;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /** apr_time_now() at the time the entity was acutally cached */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t response_time;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor};
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* cache handle information */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* XXX TODO On the next structure change/MMN bump,
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * count must become an apr_off_t, representing
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * the potential size of disk cached objects.
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * Then dig for
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * "XXX Bad Temporary Cast - see cache_object_t notes"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzortypedef struct cache_object cache_object_t;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorstruct cache_object {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const char *key;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor cache_object_t *next;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor cache_info info;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /* Opaque portion (specific to the implementation) of the cache object */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor void *vobj;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor /* FIXME: These are only required for mod_mem_cache. */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_size_t count; /* Number of body bytes written to the cache so far */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int complete;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_uint32_t refcount; /* refcount and bit flag to cleanup object */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor};
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzortypedef struct cache_handle cache_handle_t;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorstruct cache_handle {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor cache_object_t *cache_obj;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_table_t *req_hdrs; /* cached request headers */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_table_t *resp_hdrs; /* cached response headers */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor};
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#define CACHE_PROVIDER_GROUP "cache"
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzortypedef struct {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int (*remove_entity) (cache_handle_t *h);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_status_t (*store_headers)(cache_handle_t *h, request_rec *r, cache_info *i);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_status_t (*store_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_status_t (*recall_headers) (cache_handle_t *h, request_rec *r);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_status_t (*recall_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int (*create_entity) (cache_handle_t *h, request_rec *r,
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const char *urlkey, apr_off_t len);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int (*open_entity) (cache_handle_t *h, request_rec *r,
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const char *urlkey);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor int (*remove_url) (cache_handle_t *h, apr_pool_t *p);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor} cache_provider;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* A linked-list of authn providers. */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzortypedef struct cache_provider_list cache_provider_list;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorstruct cache_provider_list {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const char *provider_name;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const cache_provider *provider;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor cache_provider_list *next;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor};
576c49cd335618ad4b5351bd1c5f2cfd7584dba4lgentis
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* per request cache information */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzortypedef struct {
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor cache_provider_list *providers; /* possible cache providers */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const cache_provider *provider; /* current cache provider */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor const char *provider_name; /* current cache provider name */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis int fresh; /* is the entitey fresh? */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis cache_handle_t *handle; /* current cache handle */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis cache_handle_t *stale_handle; /* stale cache handle */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis apr_table_t *stale_headers; /* original request headers. */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis int in_checked; /* CACHE_SAVE must cache the entity */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis int block_response; /* CACHE_SAVE must block response. */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis apr_bucket_brigade *saved_brigade; /* copy of partial response */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis apr_off_t saved_size; /* length of saved_brigade */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis apr_time_t exp; /* expiration */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis apr_time_t lastmod; /* last-modified time */
d89089206f40f9a6d58528ff85050447d4a52d53lgentis cache_info *info; /* current cache info */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor ap_filter_t *remove_url_filter; /* Enable us to remove the filter */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor char *key; /* The cache key created for this
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * request
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor} cache_request_rec;
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
67972b58b9a56ebc101bea2e9758569b973dd5cand
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* cache_util.c */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* do a HTTP/1.1 age calculation */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorCACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const apr_time_t age_value,
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor apr_time_t now);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/**
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * Check the freshness of the cache object per RFC2616 section 13.2 (Expiration Model)
576c49cd335618ad4b5351bd1c5f2cfd7584dba4lgentis * @param h cache_handle_t
576c49cd335618ad4b5351bd1c5f2cfd7584dba4lgentis * @param r request_rec
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * @return 0 ==> cache object is stale, 1 ==> cache object is fresh
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorCACHE_DECLARE(int) ap_cache_check_freshness(cache_handle_t *h, request_rec *r);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis/**
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis * Merge in cached headers into the response
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis * @param h cache_handle_t
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis * @param r request_rec
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis * @param preserve_orig If 1, the values in r->headers_out are preserved.
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis * Otherwise, they are overwritten by the cached value.
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis */
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(void) ap_cache_accept_headers(cache_handle_t *h, request_rec *r,
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis int preserve_orig);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(char *) ap_cache_generate_name(apr_pool_t *p, int dirlevels,
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis int dirlength,
21b0af80656190938e7dd1d9b0a83dc803626824lgentis const char *name);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, cache_server_conf *conf, apr_uri_t uri);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis const char *key, char **val);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);
d89089206f40f9a6d58528ff85050447d4a52d53lgentis
aca6eead4bc5fed9b497b0ca21027c1bcba56054lgentis/* Create a new table consisting of those elements from an
d89089206f40f9a6d58528ff85050447d4a52d53lgentis * headers table that are allowed to be stored in a cache.
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis */
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers(apr_pool_t *pool,
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis apr_table_t *t,
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis server_rec *s);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis/* Create a new table consisting of those elements from an input
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis * headers table that are allowed to be stored in a cache.
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis */
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_in(request_rec *r);
d89089206f40f9a6d58528ff85050447d4a52d53lgentis
1b1b6ae3d9cf8a22cd74249fe56d4fab443f9e21lgentis/* Create a new table consisting of those elements from an output
d89089206f40f9a6d58528ff85050447d4a52d53lgentis * headers table that are allowed to be stored in a cache;
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis * ensure there is a content type and capture any errors.
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis */
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_out(request_rec *r);
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis
21b0af80656190938e7dd1d9b0a83dc803626824lgentis/* Legacy call - functionally equivalent to ap_cache_cacheable_headers.
21b0af80656190938e7dd1d9b0a83dc803626824lgentis * @deprecated @see ap_cache_cacheable_headers
21b0af80656190938e7dd1d9b0a83dc803626824lgentis */
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentisCACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis apr_table_t *t,
560024d8ef457c288c07cee03dd8db0ab28c2fb8lgentis server_rec *s);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/**
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * cache_storage.c
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorint cache_remove_url(cache_request_rec *cache, apr_pool_t *p);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorint cache_create_entity(request_rec *r, apr_off_t size);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorint cache_select(request_rec *r);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorapr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key );
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/**
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * create a key for the cache based on the request record
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor * this is the 'default' version, which can be overridden by a default function
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorconst char* cache_create_key( request_rec*r );
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/*
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorapr_status_t cache_store_entity_headers(cache_handle_t *h, request_rec *r, cache_info *info);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorapr_status_t cache_store_entity_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *bb);
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzorapr_status_t cache_recall_entity_headers(cache_handle_t *h, request_rec *r);
d89089206f40f9a6d58528ff85050447d4a52d53lgentisapr_status_t cache_recall_entity_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
21d31c05096a45954f47863580572da87c902d34lgentis*/
d89089206f40f9a6d58528ff85050447d4a52d53lgentis
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/* hooks */
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
21d31c05096a45954f47863580572da87c902d34lgentisAPR_DECLARE_OPTIONAL_FN(apr_status_t,
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor ap_cache_generate_key,
21d31c05096a45954f47863580572da87c902d34lgentis (request_rec *r, apr_pool_t*p, char**key ));
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#endif /*MOD_CACHE_H*/
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor/** @} */