From 90fdade566c6b3d15f1ecdaad2479fb877f9d9f6 Mon Sep 17 00:00:00 2001 From: Ana Gelez Date: Thu, 25 Jun 2020 21:49:03 +0200 Subject: [PATCH 1/2] Better caching Based on @trinity-1686a's patch: https://github.com/Plume-org/Plume/issues/786#issuecomment-647170325 --- src/template_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/template_utils.rs b/src/template_utils.rs index 26bf58b46..25c703a36 100644 --- a/src/template_utils.rs +++ b/src/template_utils.rs @@ -63,7 +63,7 @@ impl<'r> Responder<'r> for Ructe { let etag = format!("{:x}", hasher.finish()); if r.headers() .get("If-None-Match") - .any(|s| s[1..s.len() - 1] == etag) + .any(|s| s[1..s.len() - 1] == etag || s[3..s.len() - 1] == etag) { Response::build() .status(Status::NotModified) From 719fec0828ae52579dc11a708821701b3a09fbc1 Mon Sep 17 00:00:00 2001 From: Ana Gelez Date: Thu, 25 Jun 2020 22:26:44 +0200 Subject: [PATCH 2/2] Add a comment --- src/template_utils.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/template_utils.rs b/src/template_utils.rs index 25c703a36..0b1268492 100644 --- a/src/template_utils.rs +++ b/src/template_utils.rs @@ -63,6 +63,9 @@ impl<'r> Responder<'r> for Ructe { let etag = format!("{:x}", hasher.finish()); if r.headers() .get("If-None-Match") + // This check matches both weak and strong ETags + // NGINX (and maybe other software) sometimes sends ETags with a + // "W/" prefix, that we ignore here .any(|s| s[1..s.len() - 1] == etag || s[3..s.len() - 1] == etag) { Response::build()