cache_storage.c revision 61ee78d6fec267112988f5f38202ae5e9b0cb035
2N/A/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as 2N/A * Licensed under the Apache License, Version 2.0 (the "License"); 2N/A * you may not use this file except in compliance with the License. 2N/A * You may obtain a copy of the License at 2N/A * Unless required by applicable law or agreed to in writing, software 2N/A * distributed under the License is distributed on an "AS IS" BASIS, 2N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2N/A * See the License for the specific language governing permissions and 2N/A * limitations under the License. 2N/A/* -------------------------------------------------------------- */ 2N/A * delete all URL entities from the cache 2N/A /* Remove the stale cache entry if present. If not, we're 2N/A * being called from outside of a request; remove the 26N/A * non-stalle handle. 181N/A /* for each specified cache type, delete the URL */ 3739N/A * create a new URL entity in the cache 3739N/A * It is possible to store more than once entity per URL. This 3817N/A * function will always create a new entity, regardless of whether 3817N/A * other entities already exist for the same URL. 26N/A * The size of the entity is provided so that a cache module can 26N/A * decide whether or not it wants to cache this particular entity. 26N/A * If the size is unknown, a size of -1 should be set. 26N/A /* for each specified cache type, delete the URL */ 26N/A /* If the cache gave us a Last-Modified header, we can't just 379N/A * pass it on blindly because of restrictions on future values. 2818N/A /* The HTTP specification says that it is legal to merge duplicate 4910N/A * headers into one. Some browsers that support Cookies don't like 2N/A * merged headers and prefer that each Set-Cookie header is sent 26N/A * separately. Lets humour those browsers by not merging. 26N/A * Oh what a pain it is. 1256N/A * select a specific URL entity in the cache 2818N/A * It is possible to store more than one entity per URL. Content 1256N/A * negotiation is used to select an entity. Once an entity is 1256N/A * selected, details of it are stored in the per request 1256N/A * config to save time when serving the request later. 1256N/A * This function returns OK if successful, DECLINED if no 1256N/A * cached entity fits the bill. 3109N/A /* go through the cache types till we get a match */ 1256N/A /* TODO: Handle this error */ 185N/A * Check Content-Negotiation - Vary 255N/A * At this point we need to make sure that the object we found in 145N/A * the cache is the same object that would be delivered to the 7N/A * client, when the effects of content negotiation are taken into 38N/A * In plain english, we want to make sure that a language-negotiated 26N/A * document in one language is not given to a client asking for a 197N/A * language negotiated document in a different language by mistake. 197N/A * This code makes the assumption that the storage manager will 197N/A * cache the req_hdrs if the response contains a Vary 30N/A * RFC2616 13.6 and 14.44 describe the Vary mechanism. 26N/A /* isolate header name */ 1256N/A * is this header in the request and the header in the cached 2818N/A * request identical? If not, we give up and do a straight get 1256N/A /* both headers NULL, so a match - do nothing */ 1256N/A /* both headers exist and are equal - do nothing */ 1256N/A /* headers do not match, so Vary failed */ 1256N/A "cache_select_url(): Vary header mismatch.");
3817N/A /* Is our cached response fresh enough? */ 3449N/A /* Make response into a conditional */ 3449N/A /* We can only revalidate with our own conditionals: remove the 1934N/A * conditions from the original request. 1413N/A /* If we have a cached etag and/or Last-Modified add in 3449N/A /* Okay, this response looks okay. Merge in our stuff and go. */ 3109N/A /* try again with next cache type */ 3109N/A /* Use the canonical name to improve cache hit rate, but only if this is 3109N/A /* Use _default_ as the hostname if none present, as in mod_vhost */ 3449N/A /* Copy the parsed uri hostname */ 4811N/A /* We are a proxied request, with no hostname. Unlikely 4811N/A * to get very far - but just in case */ 4811N/A /* Copy the scheme, ensuring that it is lower case. If the parsed uri 4811N/A * contains no string or if this is not a proxy request. 26N/A /* If the content is locally generated, use the port-number of the 181N/A * current server. Otherwise. copy the URI's port-string (which may be a 369N/A * service name). If the URI contains no port-string, use apr-util's 181N/A * notion of the default port for that scheme - if available. 3817N/A /* No port string given in the AbsoluteUri, and we have no 3817N/A * idea what the default port for the scheme is. Leave it 3817N/A * blank and live with the inefficiency of some extra cached 185N/A /* Key format is a URI */