=== modified file 'src/errorpage.cc'
--- src/errorpage.cc	2013-03-17 12:19:16 +0000
+++ src/errorpage.cc	2013-03-21 02:33:29 +0000
@@ -1192,15 +1192,30 @@
 
 #if USE_ERR_LOCALES
         /*
-         * If error page auto-negotiate is enabled in any way, send the Vary.
+         * If error page auto-negotiate is enabled in any way, send the Vary and Key
          * RFC 2616 section 13.6 and 14.44 says MAY and SHOULD do this.
          * We have even better reasons though:
          * see http://wiki.squid-cache.org/KnowledgeBase/VaryNotCaching
          */
         if (!Config.errorDirectory) {
             /* We 'negotiated' this ONLY from the Accept-Language. */
+            String tmp = "Accept-Language";
+
+            // Vary:Accept-Language
             rep->header.delById(HDR_VARY);
-            rep->header.putStr(HDR_VARY, "Accept-Language");
+            rep->header.putStr(HDR_VARY,tmp.termedBuf());
+
+            // Key:Accept-Language;b="foo"
+            // Only supply the match parameters if the language is actually found.
+            // On the generic reply to all 'unknown' inputs we must be vague like Vary
+            // which makes the recipient use the entire Accept-Language as the variant key.
+            if (err_language) {
+                tmp.append(";b=\"");
+                tmp.append(err_language);
+                tmp.append('"');
+            }
+            rep->header.delById(HDR_KEY);
+            rep->header.putStr(HDR_KEY, tmp.termedBuf());
         }
 
         /* add the Content-Language header according to RFC section 14.12 */


