if (rv == DECLINED) {
if (!lookup) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
- "Adding CACHE_SAVE filter.");
+ "Adding CACHE_SAVE filter for %s", r->uri);
/* add cache_save filter to cache this request */
ap_add_output_filter_handle(cache_save_filter_handle, NULL, r,
r->connection);
ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
- "Adding CACHE_REMOVE_URL filter.");
+ "Adding CACHE_REMOVE_URL filter for %s",
+ r->uri);
/* Add cache_remove_url filter to this request to remove a
* stale cache entry if needed. Also put the current cache
ap_add_output_filter_handle(cache_remove_url_filter_handle,
cache, r, r->connection);
}
- else if (cache->stale_headers) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
- "Restoring request headers.");
-
- r->headers_in = cache->stale_headers;
+ else {
+ if (cache->stale_headers) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS,
+ r->server, "Restoring request headers for %s",
+ r->uri);
+
+ r->headers_in = cache->stale_headers;
+ }
+
+ /* Delete our per-request configuration. */
+ ap_set_module_config(r->request_config, &cache_module, NULL);
}
}
else {
}
return DECLINED;
}
+
+ /* if we are a lookup, we are exiting soon one way or another; Restore
+ * the headers. */
+ if (lookup) {
+ if (cache->stale_headers) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
+ "Restoring request headers.");
+ r->headers_in = cache->stale_headers;
+ }
+
+ /* Delete our per-request configuration. */
+ ap_set_module_config(r->request_config, &cache_module, NULL);
+ }
rv = ap_meets_conditions(r);
if (rv != OK) {
+ /* If we are a lookup, we have to return DECLINED as we have no
+ * way of knowing if we will be able to serve the content.
+ */
+ if (lookup) {
+ return DECLINED;
+ }
+
/* Return cached status. */
return rv;
}
request_rec *r = f->r;
cache_request_rec *cache;
cache_server_conf *conf;
- char *url = r->unparsed_uri;
const char *cc_out, *cl;
const char *exps, *lastmods, *dates, *etag;
apr_time_t exp, date, lastmod, now;
if (reason) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "cache: %s not cached. Reason: %s", url, reason);
+ "cache: %s not cached. Reason: %s", r->unparsed_uri,
+ reason);
/* remove this filter from the chain */
ap_remove_output_filter(f);
/* no cache handle, create a new entity */
if (!cache->handle) {
- rv = cache_create_entity(r, url, size);
+ rv = cache_create_entity(r, size);
info = apr_pcalloc(r->pool, sizeof(cache_info));
/* We only set info->status upon the initial creation. */
info->status = r->status;
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "cache: Caching url: %s", url);
+ "cache: Caching url: %s", r->unparsed_uri);
/* We are actually caching this response. So it does not
* make sense to remove this entity any more.
/* per request cache information */
typedef struct {
- cache_provider_list *providers; /* possible cache providers */
- const cache_provider *provider; /* current cache provider */
- const char *provider_name; /* current cache provider name */
- int fresh; /* is the entitey fresh? */
- cache_handle_t *handle; /* current cache handle */
- cache_handle_t *stale_handle; /* stale cache handle */
- apr_table_t *stale_headers; /* original request headers. */
- int in_checked; /* CACHE_SAVE must cache the entity */
- int block_response; /* CACHE_SAVE must block response. */
+ cache_provider_list *providers; /* possible cache providers */
+ const cache_provider *provider; /* current cache provider */
+ const char *provider_name; /* current cache provider name */
+ int fresh; /* is the entitey fresh? */
+ cache_handle_t *handle; /* current cache handle */
+ cache_handle_t *stale_handle; /* stale cache handle */
+ apr_table_t *stale_headers; /* original request headers. */
+ int in_checked; /* CACHE_SAVE must cache the entity */
+ int block_response; /* CACHE_SAVE must block response. */
apr_bucket_brigade *saved_brigade; /* copy of partial response */
apr_off_t saved_size; /* length of saved_brigade */
apr_time_t exp; /* expiration */
* cache_storage.c
*/
int cache_remove_url(cache_request_rec *cache, apr_pool_t *p);
-int cache_create_entity(request_rec *r, char *url, apr_off_t size);
+int cache_create_entity(request_rec *r, apr_off_t size);
int cache_select(request_rec *r);
apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key );
/**