serrislew commented on code in PR #13547:
URL: https://github.com/apache/trafficserver/pull/13547#discussion_r3806493923


##########
src/proxy/http/HttpTransact.cc:
##########
@@ -6396,8 +6396,20 @@ HttpTransact::is_stale_cache_response_returnable(State 
*s)
   time_t current_age = 
HttpTransactCache::calculate_document_age(s->cache_info.object_read->request_sent_time_get(),
                                                                  
s->cache_info.object_read->response_received_time_get(),
                                                                  
cached_response, cached_response->get_date(), s->current.now);
+
+  MgmtInt max_age       = get_max_age(cached_response);
+  MgmtInt max_stale_age = s->txn_conf->cache_max_stale_age;
+  MgmtInt max_stale_percentage =
+    std::clamp(s->txn_conf->cache_max_stale_age_percent, 
static_cast<MgmtInt>(0), static_cast<MgmtInt>(100));
+
+  if (max_stale_percentage > 0 && max_age >= 0) {
+    MgmtInt percent_max_stale_age = max_age * max_stale_percentage / 100;

Review Comment:
   The integer division in `max_age * max_stale_percentage / 100` truncates, so 
the window is 0 for any max-age < 100/percent (ex: max_stale_age_percent: 1 
zeroes the stale window for everything under max-age=100 taking those objects 
from servable for the full 7d max_stale_age to unservable after a second) 
Intended? If so, maybe add a doc note?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to