Repository: GoogleChrome/lighthouse
Pull request #5831 (2018-08-14 00:35:32)

report: make red/orange/green score color thresholds tougher
For harmony with PSI thresholds.

note that `Util.PASS_THRESHOLD` also affects when [`title` vs `failureTitle` is selected for an audit](https://github.com/GoogleChrome/lighthouse/blob/049af195ab33d40718e6fe39a278de1c2ec07ec5/lighthouse-core/audits/audit.js#L192-L196)

@paulirish


Patch:
diff --git a/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js b/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js
index 32462e039..bbea54ac7 100644
--- a/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js
+++ b/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js
@@ -185,7 +185,13 @@ class CacheHeaders extends Audit {
         /** @type {Map<string, string>} */
         const headers = new Map();
         for (const header of record.responseHeaders || []) {
-          headers.set(header.name.toLowerCase(), header.value);
+          if (headers.has(header.name.toLowerCase())) {
+            const previousHeaderValue = headers.get(header.name.toLowerCase());
+            headers.set(header.name.toLowerCase(),
+              `${previousHeaderValue}, ${header.value}`);
+          } else {
+            headers.set(header.name.toLowerCase(), header.value);
+          }
         }
 
         const cacheControl = parseCacheControl(headers.get('cache-control'));
diff --git a/lighthouse-core/report/html/renderer/util.js b/lighthouse-core/report/html/renderer/util.js
index c076d10e7..b5c3ad0c3 100644
--- a/lighthouse-core/report/html/renderer/util.js
+++ b/lighthouse-core/report/html/renderer/util.js
@@ -20,11 +20,11 @@
 
 const ELLIPSIS = '\u2026';
 const NBSP = '\xa0';
-const PASS_THRESHOLD = 0.75;
+const PASS_THRESHOLD = 0.9;
 
 const RATINGS = {
   PASS: {label: 'pass', minScore: PASS_THRESHOLD},
-  AVERAGE: {label: 'average', minScore: 0.45},
+  AVERAGE: {label: 'average', minScore: 0.5},
   FAIL: {label: 'fail'},
   ERROR: {label: 'error'},
 };


Test patch:
diff --git a/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js b/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js
index 148fa6df2..d49bae881 100644
--- a/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js
+++ b/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js
@@ -119,6 +119,25 @@ describe('Cache headers audit', () => {
     });
   });
 
+  it('respects multiple cache-control headers', () => {
+    networkRecords = [
+      networkRecord({headers: {
+        'cache-control': 'max-age=31536000, public',
+        'Cache-control': 'no-transform',
+      }}),
+      networkRecord({headers: {
+        'Cache-Control': 'no-transform',
+        'cache-control': 'max-age=3600',
+        'Cache-control': 'public',
+      }}),
+    ];
+
+    return CacheHeadersAudit.audit(artifacts, {options}).then(result => {
+      const items = result.extendedInfo.value.results;
+      assert.equal(items.length, 1);
+    });
+  });
+
   it('catches records with Etags', () => {
     networkRecords = [
       networkRecord({headers: {etag: 'md5hashhere'}}),
diff --git a/lighthouse-core/test/report/html/renderer/util-test.js b/lighthouse-core/test/report/html/renderer/util-test.js
index e53123ba3..8da03c290 100644
--- a/lighthouse-core/test/report/html/renderer/util-test.js
+++ b/lighthouse-core/test/report/html/renderer/util-test.js
@@ -83,10 +83,11 @@ describe('util helpers', () => {
   it('calculates a score ratings', () => {
     assert.equal(Util.calculateRating(0.0), 'fail');
     assert.equal(Util.calculateRating(0.10), 'fail');
-    assert.equal(Util.calculateRating(0.45), 'average');
-    assert.equal(Util.calculateRating(0.55), 'average');
-    assert.equal(Util.calculateRating(0.75), 'pass');
-    assert.equal(Util.calculateRating(0.80), 'pass');
+    assert.equal(Util.calculateRating(0.45), 'fail');
+    assert.equal(Util.calculateRating(0.5), 'average');
+    assert.equal(Util.calculateRating(0.75), 'average');
+    assert.equal(Util.calculateRating(0.80), 'average');
+    assert.equal(Util.calculateRating(0.90), 'pass');
     assert.equal(Util.calculateRating(1.00), 'pass');
   });