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=127.0.0.1 path=/stuff

#disable cacheing from special host
CacheDisable client=10.1.1.1.10

#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=10.0.0.0/255.0.0.0


#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",
                            arg);
    }
    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

Reply via email to