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


##########
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:
   Yes, this is intentional. ATS measures age in whole seconds, and because the 
percentage is an upper bound, rounding up could exceed the configured limit. I 
documented that calculations round down and that sub-one-second results permit 
no stale window, including the 1% with max-age=99 example.



-- 
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