0.34.6_repo_cleanup
This commit is contained in:
1 parent
ce1a90397c
commit
133d2f0f91
273 files changed
+5969
-6926
No files matched your search
Vendored
+10
-22
@@ -4,7 +4,11 @@ impl Plan {
|
||||
}
|
||||
|
||||
pub fn with_vary(mut self, name: &str) -> Self {
|
||||
if !self.vary.iter().any(|value| value.eq_ignore_ascii_case(name)) {
|
||||
if !self
|
||||
.vary
|
||||
.iter()
|
||||
.any(|value| value.eq_ignore_ascii_case(name))
|
||||
{
|
||||
self.vary.push(name.to_ascii_lowercase());
|
||||
self.vary.sort();
|
||||
}
|
||||
@@ -28,14 +32,7 @@ impl Plan {
|
||||
self.vary.extend(transformed.vary);
|
||||
self.vary.sort();
|
||||
self.vary.dedup();
|
||||
// The transformed response is the representation that is actually
|
||||
// written to cache. Its Content-Length therefore replaces the origin
|
||||
// length; comparing transformed bytes with the origin length rejects a
|
||||
// valid fill and causes a permanent MISS -> MISS loop.
|
||||
self.expected_length = transformed.expected_length;
|
||||
// Express both age clocks at the later observation point before taking
|
||||
// the stricter value. This avoids resetting or double-counting Age when
|
||||
// origin headers are transformed inside the proxy.
|
||||
if transformed.received >= self.received {
|
||||
let carried = self
|
||||
.initial_age
|
||||
@@ -87,9 +84,6 @@ pub fn plan(
|
||||
{
|
||||
return None;
|
||||
}
|
||||
// Cache-policy and validator fields govern reuse rather than representation
|
||||
// identity. Response Vary drives a secondary key, matching Varnish-style
|
||||
// variants without fragmenting on unrelated request headers.
|
||||
let vary = vary_names(headers)?;
|
||||
let control = directives(headers)?;
|
||||
if ["no-store", "private", "must-understand"]
|
||||
@@ -141,22 +135,16 @@ pub fn plan(
|
||||
Some(v) => v.to_str().ok()?.parse::<u64>().ok()?,
|
||||
None => 0,
|
||||
};
|
||||
// RFC 9111 Section 4.2.3: the corrected initial age is the greater of
|
||||
// the Date-derived apparent age and the received Age plus response delay.
|
||||
// An upstream/CDN Age must be preserved on both transformed and normal HITs.
|
||||
let apparent_age = now.duration_since(date).unwrap_or_default();
|
||||
let corrected_age_value = Duration::from_secs(age).saturating_add(response_delay);
|
||||
let initial_age = apparent_age.max(corrected_age_value);
|
||||
|
||||
// `ttl` is an absolute freshness lifetime (measured from the origin's
|
||||
// Age clock), not the time since insertion into our HOT/COLD cache.
|
||||
// Capping it directly to max_ttl_seconds makes an otherwise fresh 30-day
|
||||
// upstream response with Age=18 days look expired when our own cap is 1 day.
|
||||
// Limit the REMAINING freshness from admission, but preserve the Age clock.
|
||||
// Origin freshness still wins: an origin response that has already expired
|
||||
// must never become fresh here. `no-cache` continues to require validation.
|
||||
let ttl = match declared_ttl {
|
||||
Some(value) => value.min(initial_age.as_secs().saturating_add(settings.max_ttl_seconds)),
|
||||
Some(value) => value.min(
|
||||
initial_age
|
||||
.as_secs()
|
||||
.saturating_add(settings.max_ttl_seconds),
|
||||
),
|
||||
None if requires_revalidation => 0,
|
||||
None => return None,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user