MCPcopy Create free account
hub / github.com/apache/trafficserver / need_to_revalidate

Method need_to_revalidate

src/proxy/http/HttpTransact.cc:2661–2721  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Name : need_to_revalidate Description: Checks if a document which is in the cache needs to be revalidates Details : Function calls AuthenticationNeeded and is_cache_response_returnable to determine if the cached document can be served ////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

2659// if the cached document can be served
2660/////////////////////////////////////////////////////////////////////////////
2661bool
2662HttpTransact::need_to_revalidate(State *s)
2663{
2664 bool needs_revalidate, needs_authenticate = false;
2665 bool needs_cache_auth = false;
2666 CacheHTTPInfo *obj;
2667
2668 if (s->api_update_cached_object == HttpTransact::UPDATE_CACHED_OBJECT_CONTINUE) {
2669 obj = &s->cache_info.object_store;
2670 ink_assert(obj->valid());
2671 if (!obj->valid()) {
2672 return true;
2673 }
2674 } else {
2675 obj = s->cache_info.object_read;
2676 }
2677
2678 // do we have to authenticate with the server before
2679 // sending back the cached response to the client?
2680 Authentication_t authentication_needed = AuthenticationNeeded(s->txn_conf, &s->hdr_info.client_request, obj->response_get());
2681
2682 switch (authentication_needed) {
2683 case AUTHENTICATION_SUCCESS:
2684 TxnDbg(dbg_ctl_http_seq, "Authentication not needed");
2685 needs_authenticate = false;
2686 break;
2687 case AUTHENTICATION_MUST_REVALIDATE:
2688 SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_METHOD);
2689 TxnDbg(dbg_ctl_http_seq, "Authentication needed");
2690 needs_authenticate = true;
2691 break;
2692 case AUTHENTICATION_MUST_PROXY:
2693 TxnDbg(dbg_ctl_http_seq, "Authentication needed");
2694 needs_authenticate = true;
2695 break;
2696 case AUTHENTICATION_CACHE_AUTH:
2697 TxnDbg(dbg_ctl_http_seq, "Authentication needed for cache_auth_content");
2698 needs_authenticate = false;
2699 needs_cache_auth = true;
2700 break;
2701 default:
2702 ink_assert(!("AuthenticationNeeded has returned unsupported code."));
2703 return true;
2704 break;
2705 }
2706
2707 ink_assert(is_cache_hit(s->cache_lookup_result));
2708 if (s->cache_lookup_result == CACHE_LOOKUP_HIT_STALE &&
2709 s->api_update_cached_object != HttpTransact::UPDATE_CACHED_OBJECT_CONTINUE) {
2710 needs_revalidate = true;
2711 } else {
2712 needs_revalidate = false;
2713 }
2714
2715 bool send_revalidate = ((needs_authenticate == true) || (needs_revalidate == true) || (is_cache_response_returnable(s) == false));
2716 if (needs_cache_auth == true) {
2717 s->www_auth_content = send_revalidate ? CACHE_AUTH_STALE : CACHE_AUTH_FRESH;
2718 send_revalidate = true;

Callers

nothing calls this directly

Calls 2

response_getMethod · 0.80
validMethod · 0.45

Tested by

no test coverage detected