Hi,

During last week's training it came up. People were confused to see
so much information with varnishlog but not something they consider
important. It would be useful/comforting to them to see it when
troubleshooting Varnish.

I personally don't have an opinion, it's been a while since I last had
to deal with Varnish in production. I made this patch because it is
trivial.

Best Regards,
Dridi
From 02db0bf950f79625d787390d4f2e51a6607280dc Mon Sep 17 00:00:00 2001
From: Dridi Boukelmoune <dridi.boukelmo...@gmail.com>
Date: Fri, 11 Sep 2015 15:57:49 +0200
Subject: [PATCH] Log 'set beresp.uncacheable = true' occurrences

---
 bin/varnishd/cache/cache_vrt_var.c |  1 +
 bin/varnishtest/tests/v00045.vtc   | 19 +++++++++++++++++++
 include/tbl/vsl_tags.h             |  5 +++++
 3 files changed, 25 insertions(+)
 create mode 100644 bin/varnishtest/tests/v00045.vtc

diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index c51007b..1123ef1 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -221,6 +221,7 @@ VRT_l_beresp_uncacheable(VRT_CTX, unsigned a)
 		    "Ignoring attempt to reset beresp.uncacheable");
 	} else if (a) {
 		ctx->bo->uncacheable = 1;
+		VSLb(ctx->vsl, SLT_Uncacheable, "%u", VXID(ctx->vsl->wid));
 	}
 }
 
diff --git a/bin/varnishtest/tests/v00045.vtc b/bin/varnishtest/tests/v00045.vtc
new file mode 100644
index 0000000..2019e92
--- /dev/null
+++ b/bin/varnishtest/tests/v00045.vtc
@@ -0,0 +1,19 @@
+varnishtest "Log when beresp is made uncacheable"
+
+server s1 {
+	rxreq
+	txresp -hdr "Cache-Control: no-cache"
+} -start
+
+varnish v1 -vcl+backend "" -start
+
+logexpect l1 -v v1 -g session {
+	expect * 1002 Uncacheable 1002
+} -start
+
+client c1 {
+	txreq
+	rxresp
+} -run
+
+logexpect l1 -wait
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 56a9604..0e264d0 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -522,5 +522,10 @@ SLTM(Witness, 0, "Lock order witness records",
 	"Diagnostic recording of locking order.\n"
 )
 
+SLTM(Uncacheable, 0, "Uncacheable object in VCL",
+	"Backend response marked as uncacheable. "
+	"Shows the VXID of the object.\n\n"
+)
+
 #undef NODEF_NOTICE
 /*lint -restore */
-- 
2.4.3

_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to