Ref: https://tools.ietf.org/html/rfc7231#section-6.1

Changes:

* 302 Found
* 307 Temporary Redirect

  Do not apply the default ttl, only set a ttl if Cache-Control or Expires are
present.
  Responses with these status codes are not cacheable by default

* 414 Request-URI Too Large

  Cacheable with "heuristic expiration"
>From 19b8290645ef64da7fce02a425b14b9d892160c6 Mon Sep 17 00:00:00 2001
From: Nils Goroll <[email protected]>
Date: Thu, 18 Dec 2014 10:57:28 +0100
Subject: [PATCH] Improve application of the default ttl by response status
 code

Ref: https://tools.ietf.org/html/rfc7231#section-6.1

Changes:

* 302 Found
* 307 Temporary Redirect

  Do not apply the default ttl, only set a ttl if Cache-Control or Expires are present.
  Responses with these status codes are not cacheable by default

* 414 Request-URI Too Large

  Cacheable with "heuristic expiration"
---
 bin/varnishd/cache/cache_rfc2616.c | 11 +++++++----
 bin/varnishtest/tests/b00015.vtc   |  6 +++---
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index 3d66fe5..6a59657 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -112,15 +112,18 @@ RFC2616_Ttl(struct busyobj *bo, double now)
 	default:
 		expp->ttl = -1.;
 		break;
+	case 302: /* Moved Temporarily */
+	case 307: /* Temporary Redirect */
+		expp->ttl = -1.;
 	case 200: /* OK */
 	case 203: /* Non-Authoritative Information */
+	case 204: /* No Content */
 	case 300: /* Multiple Choices */
 	case 301: /* Moved Permanently */
-	case 302: /* Moved Temporarily */
-	case 304: /* Not Modified */
-	case 307: /* Temporary Redirect */
-	case 410: /* Gone */
+	case 304: /* Not Modified - handled like 200 */
 	case 404: /* Not Found */
+	case 410: /* Gone */
+	case 414: /* Request-URI Too Large */
 		/*
 		 * First find any relative specification from the backend
 		 * These take precedence according to RFC2616, 13.2.4
diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc
index 029f782..e26b16d 100644
--- a/bin/varnishtest/tests/b00015.vtc
+++ b/bin/varnishtest/tests/b00015.vtc
@@ -32,7 +32,7 @@ varnish v1 -cliok "ban req.url ~ .*"
 
 server s1 {
 	rxreq
-	txresp -status 302
+	txresp -status 301
 } -start
 
 varnish v1 -vcl+backend {
@@ -45,7 +45,7 @@ varnish v1 -vcl+backend {
 client c1 {
 	txreq -url "/"
 	rxresp
-	expect resp.status == 302
+	expect resp.status == 301
 	expect resp.http.X-varnish == "1007"
 } -run
 
@@ -54,7 +54,7 @@ delay .1
 client c1 {
 	txreq -url "/"
 	rxresp
-	expect resp.status == 302
+	expect resp.status == 301
 	expect resp.http.X-varnish == "1010 1008"
 } -run
 
-- 
2.1.3

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to