httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Akins <>
Subject Re: mod_cache wishlist
Date Tue, 23 Aug 2005 15:20:58 GMT

Some pseudo match configs and code:

Just examples, maybe not useful or doable.

#only cache things in /stuff when request comes from localhost
CacheEnable disk client= path=/stuff

#disable cacheing from special host
CacheDisable client=

#don't cache any ssl stuff
CacheDisable protocol=https

#be evil and cache post's
CacheEnable disk method=POST

#cache everything that ends in .gif
CacheEnable disk path=\.gif$

#or maybe regex=\.gif$

#Only cache php from test hosts
CacheEnable mem path=\.php$ client=

#also have not's
CacheEnable disk path!=\.gif$

# A twist on Colm's suggestion
#don't cache if env NOCACHE is set
CacheDisable env=NOCACHE

modules could register init and match functions:

typedef const char *ap_cache_match_init(apr_pool_t *p, server_rec *s, 
const char *arg, void **ptr);

typedef int ap_cache_match_func(request_rec *r, const void *arg);

APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cache_register_match,
                         (const char *name, ap_cache_match_init *init,
                          ap_cache_match_func *func));

Example match functions:

static void *regex_init(apr_pool_t *p, server_rec *s, const char *arg, 
void **ptr) {

     if((*ptr = ap_pregcomp(p, arg, REG_EXTENDED)) == NULL) {
         return apr_psprintf(p,
                             "regex compilation failed for %s",
     return NULL;

static int regex_func(request_rec *r, const void *arg) {
     regmatch_t m[MAX_REG_MATCH];

     return (!regexec((regex_t)*arg, r->uri, MAX_REG_MATCH, m, 0));

/*then in pre_cong maybe register it*/
static APR_OPTIONAL_FN_TYPE(ap_cache_register_match) *pfn_register;

pfn_register = APR_RETRIEVE_OPTIONAL_FN(ap_cache_register_match);

pfn_register("regex", regex_init, regex_func);

Brian Akins
Lead Systems Engineer
CNN Internet Technologies

View raw message