Skip to content

Commit

Permalink
Merge extensions between old and new meta on revalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
drcaramelsyrup authored and eaufavor committed Oct 11, 2024
1 parent af565b4 commit 3c3dc7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
089f8397486e934dbbe045085ba3648e0bb945a5
08724db8653366f6eee60a3236ed9c2987402fc0
7 changes: 6 additions & 1 deletion pingora-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion pingora-cache/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit 3c3dc7e

Please sign in to comment.