aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-cache
diff options
context:
space:
mode:
authorEdward Wang <[email protected]>2024-09-02 20:41:50 -0700
committerYuchen Wu <[email protected]>2024-10-11 15:40:59 -0700
commit3c3dc7ee2f207c3c2fbe712bc6a493167094df7c (patch)
tree135e86b77fd53d7fd75584eb0461df53eb595e5b /pingora-cache
parentaf565b4e24f1b8e4d7f1b7224d62b8029c580496 (diff)
downloadpingora-3c3dc7ee2f207c3c2fbe712bc6a493167094df7c.tar.gz
pingora-3c3dc7ee2f207c3c2fbe712bc6a493167094df7c.zip
Merge extensions between old and new meta on revalidate
Diffstat (limited to 'pingora-cache')
-rw-r--r--pingora-cache/src/lib.rs7
-rw-r--r--pingora-cache/src/meta.rs2
2 files changed, 7 insertions, 2 deletions
diff --git a/pingora-cache/src/lib.rs b/pingora-cache/src/lib.rs
index 8f88299..1a97041 100644
--- a/pingora-cache/src/lib.rs
+++ b/pingora-cache/src/lib.rs
@@ -719,10 +719,15 @@ impl HttpCache {
// that requires cacheable_filter to take a mut header and just return InternalMeta
// update new meta with old meta's created time
- let created = inner.meta.as_ref().unwrap().0.internal.created;
+ let old_meta = inner.meta.take().unwrap();
+ let created = old_meta.0.internal.created;
meta.0.internal.created = created;
// meta.internal.updated was already set to new meta's `created`,
// no need to set `updated` here
+ // Merge old extensions with new ones. New exts take precedence if they conflict.
+ let mut extensions = old_meta.0.extensions;
+ extensions.extend(meta.0.extensions);
+ meta.0.extensions = extensions;
inner.meta.replace(meta);
diff --git a/pingora-cache/src/meta.rs b/pingora-cache/src/meta.rs
index 8ed034e..fd608d4 100644
--- a/pingora-cache/src/meta.rs
+++ b/pingora-cache/src/meta.rs
@@ -14,7 +14,7 @@
//! Metadata for caching
-use http::Extensions;
+pub use http::Extensions;
use pingora_error::{Error, ErrorType::*, OrErr, Result};
use pingora_http::{HMap, ResponseHeader};
use serde::{Deserialize, Serialize};