[experimental-ims] 9765e50 Fiddle the "RFC" SLT_TTL record into submission.

Geoff Simmons geoff at varnish-cache.org
Wed Aug 31 16:00:20 CEST 2011


commit 9765e5026d9572267b3774979ccfe31d77cf624c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Aug 10 09:06:58 2011 +0000

    Fiddle the "RFC" SLT_TTL record into submission.
    
    Document the TTL record.

diff --git a/bin/varnishd/rfc2616.c b/bin/varnishd/rfc2616.c
index 69637ea..045eacb 100644
--- a/bin/varnishd/rfc2616.c
+++ b/bin/varnishd/rfc2616.c
@@ -89,6 +89,16 @@ RFC2616_Ttl(const struct sess *sp)
 	 * We do not support ranges yet, so 206 is out.
 	 */
 
+	if (http_GetHdr(hp, H_Age, &p)) {
+		age = strtoul(p, NULL, 0);
+		sp->wrk->exp.age = age;
+	}
+	if (http_GetHdr(hp, H_Expires, &p))
+		h_expires = TIM_parse(p);
+
+	if (http_GetHdr(hp, H_Date, &p))
+		h_date = TIM_parse(p);
+
 	switch (sp->err_code) {
 	default:
 		sp->wrk->exp.ttl = -1.;
@@ -114,10 +124,6 @@ RFC2616_Ttl(const struct sess *sp)
 				max_age = 0;
 			else
 				max_age = strtoul(p, NULL, 0);
-			if (http_GetHdr(hp, H_Age, &p)) {
-				age = strtoul(p, NULL, 0);
-				sp->wrk->exp.age = age;
-			}
 
 			if (age > max_age)
 				ttl = 0;
@@ -126,17 +132,10 @@ RFC2616_Ttl(const struct sess *sp)
 			break;
 		}
 
-		/* Next look for absolute specifications from backend */
-
-		if (http_GetHdr(hp, H_Expires, &p))
-			h_expires = TIM_parse(p);
-
 		/* No expire header, fall back to default */
 		if (h_expires == 0)
 			break;
 
-		if (http_GetHdr(hp, H_Date, &p))
-			h_date = TIM_parse(p);
 
 		/* If backend told us it is expired already, don't cache. */
 		if (h_expires < h_date) {
@@ -169,8 +168,8 @@ RFC2616_Ttl(const struct sess *sp)
 
 	/* calculated TTL, Our time, Date, Expires, max-age, age */
 	WSP(sp, SLT_TTL,
-	    "%u RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u %u",
-	    sp->xid, ttl, -1. -1., sp->wrk->exp.entered, sp->wrk->exp.age,
+	    "%u RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u",
+	    sp->xid, ttl, -1., -1., sp->wrk->exp.entered, sp->wrk->exp.age,
 	     h_date, h_expires, max_age);
 
 	return (ttl);
diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst
index ac1026a..e9f2ff3 100644
--- a/doc/sphinx/reference/vsl.rst
+++ b/doc/sphinx/reference/vsl.rst
@@ -4,6 +4,38 @@
 Shared Memory Logging
 =====================
 
+TTL records
+~~~~~~~~~~~
+
+A TTL record is emitted whenever the ttl, grace or keep values for an
+object is set.
+
+The format is::
+
+	%u %s %d %d %d %d %d [ %d %u %u ]
+	|  |  |  |  |  |  |    |  |  |
+	|  |  |  |  |  |  |    |  |  +- Max-Age from Cache-Control header
+	|  |  |  |  |  |  |    |  +---- Expires header
+	|  |  |  |  |  |  |    +------- Date header
+	|  |  |  |  |  |  +------------ Age (incl Age: header value)
+	|  |  |  |  |  +--------------- Reference time for TTL
+	|  |  |  |  +------------------ Keep
+	|  |  |  +--------------------- Grace
+	|  |  +------------------------ TTL
+	|  +--------------------------- "RFC" or "VCL"
+	+------------------------------ object XID
+
+The last three fields are only present in "RFC" headers.
+
+Examples::
+
+	1001 RFC 19 -1 -1 1312966109 4 0 0 23
+	1001 VCL 10 -1 -1 1312966109 4
+	1001 VCL 7 -1 -1 1312966111 6
+	1001 VCL 7 120 -1 1312966111 6
+	1001 VCL 7 120 3600 1312966111 6
+	1001 VCL 12 120 3600 1312966113 8
+
 Gzip records
 ~~~~~~~~~~~~
 
@@ -14,7 +46,6 @@ gunziped, will run into many of these.
 
 The format is::
 
-
 	%c %c %c %d %d %d %d %d
 	|  |  |  |  |  |  |  |
 	|  |  |  |  |  |  |  +- Bit length of compressed data
@@ -26,7 +57,7 @@ The format is::
 	|  +------------------- 'F' = Fetch, 'D' = Deliver
 	+---------------------- 'G' = Gzip, 'U' = Gunzip, 'u' = Gunzip-test
 
-Which in practice could look like::
+Examples::
 
 	U F E 182 159 80 80 1392
 	G F E 159 173 80 1304 1314



More information about the varnish-commit mailing list