| 531 | } |
| 532 | |
| 533 | int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, |
| 534 | request_rec *r) |
| 535 | { |
| 536 | apr_status_t status; |
| 537 | apr_int64_t age, maxage_req, maxage_cresp, maxage, smaxage, maxstale; |
| 538 | apr_int64_t minfresh; |
| 539 | const char *cc_req; |
| 540 | const char *pragma; |
| 541 | const char *agestr = NULL; |
| 542 | apr_time_t age_c = 0; |
| 543 | cache_info *info = &(h->cache_obj->info); |
| 544 | const char *warn_head; |
| 545 | cache_server_conf *conf = |
| 546 | (cache_server_conf *)ap_get_module_config(r->server->module_config, |
| 547 | &cache_module); |
| 548 | |
| 549 | /* |
| 550 | * We now want to check if our cached data is still fresh. This depends |
| 551 | * on a few things, in this order: |
| 552 | * |
| 553 | * - RFC2616 14.9.4 End to end reload, Cache-Control: no-cache. no-cache |
| 554 | * in either the request or the cached response means that we must |
| 555 | * perform the request unconditionally, and ignore cached content. We |
| 556 | * should never reach here, but if we do, mark the content as stale, |
| 557 | * as this is the best we can do. |
| 558 | * |
| 559 | * - RFC2616 14.32 Pragma: no-cache This is treated the same as |
| 560 | * Cache-Control: no-cache. |
| 561 | * |
| 562 | * - RFC2616 14.9.3 Cache-Control: max-stale, must-revalidate, |
| 563 | * proxy-revalidate if the max-stale request header exists, modify the |
| 564 | * stale calculations below so that an object can be at most <max-stale> |
| 565 | * seconds stale before we request a revalidation, _UNLESS_ a |
| 566 | * must-revalidate or proxy-revalidate cached response header exists to |
| 567 | * stop us doing this. |
| 568 | * |
| 569 | * - RFC2616 14.9.3 Cache-Control: s-maxage the origin server specifies the |
| 570 | * maximum age an object can be before it is considered stale. This |
| 571 | * directive has the effect of proxy|must revalidate, which in turn means |
| 572 | * simple ignore any max-stale setting. |
| 573 | * |
| 574 | * - RFC2616 14.9.4 Cache-Control: max-age this header can appear in both |
| 575 | * requests and responses. If both are specified, the smaller of the two |
| 576 | * takes priority. |
| 577 | * |
| 578 | * - RFC2616 14.21 Expires: if this request header exists in the cached |
| 579 | * entity, and it's value is in the past, it has expired. |
| 580 | * |
| 581 | */ |
| 582 | |
| 583 | /* This value comes from the client's initial request. */ |
| 584 | cc_req = apr_table_get(r->headers_in, "Cache-Control"); |
| 585 | pragma = apr_table_get(r->headers_in, "Pragma"); |
| 586 | |
| 587 | ap_cache_control(r, &cache->control_in, cc_req, pragma, r->headers_in); |
| 588 | |
| 589 | if (cache->control_in.no_cache) { |
| 590 |
no test coverage detected