| 2561 | } |
| 2562 | |
| 2563 | void |
| 2564 | HttpTransact::HandleCacheOpenReadHitFreshness(State *s) |
| 2565 | { |
| 2566 | CacheHTTPInfo *&obj = s->cache_info.object_read; |
| 2567 | |
| 2568 | ink_release_assert((s->request_sent_time == UNDEFINED_TIME) && (s->response_received_time == UNDEFINED_TIME)); |
| 2569 | TxnDbg(dbg_ctl_http_seq, "Hit in cache"); |
| 2570 | |
| 2571 | if (delete_all_document_alternates_and_return(s, true)) { |
| 2572 | TxnDbg(dbg_ctl_http_trans, "Delete and return"); |
| 2573 | s->cache_info.action = CACHE_DO_DELETE; |
| 2574 | s->next_action = HttpTransact::SM_ACTION_INTERNAL_CACHE_DELETE; |
| 2575 | return; |
| 2576 | } |
| 2577 | |
| 2578 | s->request_sent_time = obj->request_sent_time_get(); |
| 2579 | s->response_received_time = obj->response_received_time_get(); |
| 2580 | |
| 2581 | // There may be clock skew if one of the machines |
| 2582 | // went down and we do not have the correct delta |
| 2583 | // for it. this is just to deal with the effects |
| 2584 | // of the skew by setting minimum and maximum times |
| 2585 | // so that ages are not negative, etc. |
| 2586 | s->request_sent_time = std::min(s->client_request_time, s->request_sent_time); |
| 2587 | s->response_received_time = std::min(s->client_request_time, s->response_received_time); |
| 2588 | |
| 2589 | ink_assert(s->request_sent_time <= s->response_received_time); |
| 2590 | |
| 2591 | TxnDbg(dbg_ctl_http_trans, "request_sent_time : %" PRId64, (int64_t)s->request_sent_time); |
| 2592 | TxnDbg(dbg_ctl_http_trans, "response_received_time : %" PRId64, (int64_t)s->response_received_time); |
| 2593 | // if the plugin has already decided the freshness, we don't need to |
| 2594 | // do it again |
| 2595 | if (s->cache_lookup_result == HttpTransact::CACHE_LOOKUP_NONE) { |
| 2596 | // is the document still fresh enough to be served back to |
| 2597 | // the client without revalidation? |
| 2598 | Freshness_t freshness = what_is_document_freshness(s, &s->hdr_info.client_request, obj->response_get()); |
| 2599 | switch (freshness) { |
| 2600 | case FRESHNESS_FRESH: |
| 2601 | TxnDbg(dbg_ctl_http_seq, "Fresh copy"); |
| 2602 | s->cache_lookup_result = HttpTransact::CACHE_LOOKUP_HIT_FRESH; |
| 2603 | break; |
| 2604 | case FRESHNESS_WARNING: |
| 2605 | TxnDbg(dbg_ctl_http_seq, "Heuristic-based Fresh copy"); |
| 2606 | s->cache_lookup_result = HttpTransact::CACHE_LOOKUP_HIT_WARNING; |
| 2607 | break; |
| 2608 | case FRESHNESS_STALE: |
| 2609 | TxnDbg(dbg_ctl_http_seq, "Stale in cache"); |
| 2610 | s->cache_lookup_result = HttpTransact::CACHE_LOOKUP_HIT_STALE; |
| 2611 | break; |
| 2612 | default: |
| 2613 | ink_assert(!("what_is_document_freshness has returned unsupported code.")); |
| 2614 | break; |
| 2615 | } |
| 2616 | } |
| 2617 | |
| 2618 | ink_assert(s->cache_lookup_result != HttpTransact::CACHE_LOOKUP_MISS); |
| 2619 | if (s->cache_lookup_result == HttpTransact::CACHE_LOOKUP_HIT_STALE) { |
| 2620 | SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_EXPIRED); |
nothing calls this directly
no test coverage detected