[master] 9e174d4 Log cacheability

Guillaume Quintard guillaume at varnish-software.com
Thu Mar 8 18:22:07 UTC 2018


commit 9e174d4c1d38b752e029d25c28127f9eeace39c9
Author: Guillaume Quintard <guillaume at varnish-software.com>
Date:   Tue Mar 6 12:27:16 2018 +0100

    Log cacheability

diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index cef9b39..ddecb9c 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -198,9 +198,10 @@ RFC2616_Ttl(struct busyobj *bo, double now, double *t_origin,
 	}
 
 	VSLb(bo->vsl, SLT_TTL,
-	    "RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u",
+	    "RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u %s",
 	    *ttl, *grace, *keep, now,
-	    *t_origin, h_date, h_expires, max_age);
+	    *t_origin, h_date, h_expires, max_age,
+	    bo->uncacheable ? "uncacheable" : "cacheable");
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 11c8e5a..5ac0a00 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -105,7 +105,7 @@ VRT_hit_for_pass(VRT_CTX, VCL_DURATION d)
 	oc->ttl = d;
 	oc->grace = 0.0;
 	oc->keep = 0.0;
-	VSLb(ctx->vsl, SLT_TTL, "HFP %.0f %.0f %.0f %.0f",
+	VSLb(ctx->vsl, SLT_TTL, "HFP %.0f %.0f %.0f %.0f uncacheable",
 	    oc->ttl, oc->grace, oc->keep, oc->t_origin);
 }
 
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 05f058a..2d08ffa 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -229,8 +229,11 @@ VRT_r_bereq_uncacheable(VRT_CTX)
 VCL_VOID
 VRT_l_beresp_uncacheable(VRT_CTX, VCL_BOOL a)
 {
+	struct objcore *oc;
+
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(ctx->bo->fetch_objcore, OBJCORE_MAGIC);
 
 	if (ctx->bo->uncacheable && !a) {
 		VSLb(ctx->vsl, SLT_VCL_Error,
@@ -238,6 +241,11 @@ VRT_l_beresp_uncacheable(VRT_CTX, VCL_BOOL a)
 	} else if (a) {
 		ctx->bo->uncacheable = 1;
 	}
+	oc = ctx->bo->fetch_objcore;
+
+	VSLb(ctx->vsl, SLT_TTL, "VCL %.0f %.0f %.0f %.0f %s",	\
+	    oc->ttl, oc->grace, oc->keep, oc->t_origin,		\
+	    ctx->bo->uncacheable ? "uncacheable" : "cacheable");\
 }
 
 VCL_BOOL
@@ -598,8 +606,9 @@ VRT_l_##which##_##fld(VRT_CTX, VCL_DURATION a)			\
 	if (a < 0.0)						\
 		a = 0.0;					\
 	oc->fld = a;						\
-	VSLb(ctx->vsl, SLT_TTL, "VCL %.0f %.0f %.0f %.0f",	\
-	    oc->ttl, oc->grace, oc->keep, oc->t_origin);	\
+	VSLb(ctx->vsl, SLT_TTL, "VCL %.0f %.0f %.0f %.0f %s",	\
+	    oc->ttl, oc->grace, oc->keep, oc->t_origin,		\
+	    ctx->bo->uncacheable ? "uncacheable" : "cacheable");\
 }
 
 #define VRT_DO_EXP_R(which, oc, fld, offset)			\
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 728011b..89a422a 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -209,25 +209,27 @@ SLTM(LostHeader, 0, "Failed attempt to set HTTP header",
 
 SLTM(TTL, 0, "TTL set on object",
 	"A TTL record is emitted whenever the ttl, grace or keep"
-	" values for an object is set.\n\n"
+	" values for an object is set as well as whether the object is "
+	" cacheable or not.\n\n"
 	"The format is::\n\n"
-	"\t%s %d %d %d %d [ %d %d %u %u ]\n"
-	"\t|  |  |  |  |    |  |  |  |\n"
-	"\t|  |  |  |  |    |  |  |  +- Max-Age from Cache-Control header\n"
-	"\t|  |  |  |  |    |  |  +---- Expires header\n"
-	"\t|  |  |  |  |    |  +------- Date header\n"
-	"\t|  |  |  |  |    +---------- Age (incl Age: header value)\n"
-	"\t|  |  |  |  +--------------- Reference time for TTL\n"
-	"\t|  |  |  +------------------ Keep\n"
-	"\t|  |  +--------------------- Grace\n"
-	"\t|  +------------------------ TTL\n"
-	"\t+--------------------------- \"RFC\", \"VCL\" or \"HFP\"\n"
+	"\t%s %d %d %d %d [ %d %d %u %u ] %s\n"
+	"\t|  |  |  |  |    |  |  |  |    |\n"
+	"\t|  |  |  |  |    |  |  |  |    +- \"cacheable\" or \"uncacheable\"\n"
+	"\t|  |  |  |  |    |  |  |  +------ Max-Age from Cache-Control header\n"
+	"\t|  |  |  |  |    |  |  +--------- Expires header\n"
+	"\t|  |  |  |  |    |  +------------ Date header\n"
+	"\t|  |  |  |  |    +--------------- Age (incl Age: header value)\n"
+	"\t|  |  |  |  +-------------------- Reference time for TTL\n"
+	"\t|  |  |  +----------------------- Keep\n"
+	"\t|  |  +-------------------------- Grace\n"
+	"\t|  +----------------------------- TTL\n"
+	"\t+-------------------------------- \"RFC\", \"VCL\" or \"HFP\"\n"
 	"\n"
-	"The last four fields are only present in \"RFC\" headers.\n\n"
+	"The four optional fields are only present in \"RFC\" headers.\n\n"
 	"Examples::\n\n"
-	"\tRFC 60 10 -1 1312966109 1312966109 1312966109 0 60\n"
-	"\tVCL 120 10 0 1312966111\n"
-	"\tHFP 2 0 0 1312966113\n"
+	"\tRFC 60 10 -1 1312966109 1312966109 1312966109 0 60 cacheable\n"
+	"\tVCL 120 10 0 1312966111 uncacheable\n"
+	"\tHFP 2 0 0 1312966113 uncacheable\n"
 	"\n"
 )
 


More information about the varnish-commit mailing list