Description: Fix bug which prevented squid from caching responses with Vary header
Origin: upstream, http://bazaar.launchpad.net/~squid/squid/3-trunk/revision/13179
Author: Alex Rousskov <rousskov@measurement-factory.com>
Bug: http://bugs.squid-cache.org/show_bug.cgi?id=3806
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/squid3/+bug/1336742
Index: bug-1336742/src/MemStore.cc
===================================================================
--- bug-1336742.orig/src/MemStore.cc
+++ bug-1336742/src/MemStore.cc
@@ -310,6 +310,12 @@ MemStore::considerKeeping(StoreEntry &e)
         return;
     }
 
+    if (e.mem_obj->vary_headers) {
+        // XXX: We must store/load SerialisedMetaData to cache Vary in RAM
+        debugs(20, 5, "Vary not yet supported: " << e.mem_obj->vary_headers);
+        return;
+    }
+
     keep(e); // may still fail
 }
 
Index: bug-1336742/src/client_side_reply.cc
===================================================================
--- bug-1336742.orig/src/client_side_reply.cc
+++ bug-1336742/src/client_side_reply.cc
@@ -499,6 +499,7 @@ clientReplyContext::cacheHit(StoreIOBuff
 
     if (strcmp(e->mem_obj->url, urlCanonical(r)) != 0) {
         debugs(33, DBG_IMPORTANT, "clientProcessHit: URL mismatch, '" << e->mem_obj->url << "' != '" << urlCanonical(r) << "'");
+        http->logType = LOG_TCP_MISS; // we lack a more precise LOG_*_MISS code
         processMiss();
         return;
     }
@@ -530,6 +531,7 @@ clientReplyContext::cacheHit(StoreIOBuff
     case VARY_CANCEL:
         /* varyEvaluateMatch found a object loop. Process as miss */
         debugs(88, DBG_IMPORTANT, "clientProcessHit: Vary object loop!");
+        http->logType = LOG_TCP_MISS; // we lack a more precise LOG_*_MISS code
         processMiss();
         return;
     }
Index: bug-1336742/src/store.cc
===================================================================
--- bug-1336742.orig/src/store.cc
+++ bug-1336742/src/store.cc
@@ -780,12 +780,14 @@ StoreEntry::setPublicKey()
             }
 
 #endif
-            pe->replaceHttpReply(rep);
+            pe->replaceHttpReply(rep, false); // no write until key is public
 
             pe->timestampsSet();
 
             pe->makePublic();
 
+            pe->startWriting(); // after makePublic()
+
             pe->complete();
 
             pe->unlock();
