MCPcopy Index your code
hub / github.com/apache/httpd / cache_select

Function cache_select

modules/cache/cache_storage.c:214–426  ·  view source on GitHub ↗

* select a specific URL entity in the cache * * It is possible to store more than one entity per URL. Content * negotiation is used to select an entity. Once an entity is * selected, details of it are stored in the per request * config to save time when serving the request later. * * This function returns OK if successful, DECLINED if no * cached entity fits the bill. */

Source from the content-addressed store, hash-verified

212 * cached entity fits the bill.
213 */
214int cache_select(cache_request_rec *cache, request_rec *r)
215{
216 cache_provider_list *list;
217 apr_status_t rv;
218 cache_handle_t *h;
219
220 if (!cache) {
221 /* This should never happen */
222 ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r, APLOGNO(00693)
223 "cache: No cache request information available for key"
224 " generation");
225 return DECLINED;
226 }
227
228 /* if no-cache, we can't serve from the cache, but we may store to the
229 * cache.
230 */
231 if (!ap_cache_check_no_cache(cache, r)) {
232 return DECLINED;
233 }
234
235 if (!cache->key) {
236 rv = cache_generate_key(r, r->pool, &cache->key);
237 if (rv != APR_SUCCESS) {
238 return DECLINED;
239 }
240 }
241
242 /* go through the cache types till we get a match */
243 h = apr_palloc(r->pool, sizeof(cache_handle_t));
244
245 list = cache->providers;
246
247 while (list) {
248 switch ((rv = list->provider->open_entity(h, r, cache->key))) {
249 case OK: {
250 char *vary = NULL;
251 int mismatch = 0;
252 char *last = NULL;
253
254 if (list->provider->recall_headers(h, r) != APR_SUCCESS) {
255 /* try again with next cache type */
256 list = list->next;
257 continue;
258 }
259
260 /*
261 * Check Content-Negotiation - Vary
262 *
263 * At this point we need to make sure that the object we found in
264 * the cache is the same object that would be delivered to the
265 * client, when the effects of content negotiation are taken into
266 * effect.
267 *
268 * In plain english, we want to make sure that a language-negotiated
269 * document in one language is not given to a client asking for a
270 * language negotiated document in a different language by mistake.
271 *

Callers 2

cache_quick_handlerFunction · 0.85
cache_handlerFunction · 0.85

Calls 10

ap_cache_check_no_cacheFunction · 0.85
cache_strqtokFunction · 0.85
cache_table_getmFunction · 0.85
ap_condition_if_matchFunction · 0.85
ap_condition_if_rangeFunction · 0.85
cache_check_freshnessFunction · 0.85
cache_accept_headersFunction · 0.85

Tested by

no test coverage detected