From d83f150810bd37dafb5c8ab234e882e3f0a3df2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 7 May 2015 19:13:59 +0200 Subject: [PATCH] New assetsNotGzipped rule --- front/src/views/rule.html | 5 +++++ lib/metadata/policies.js | 30 ++++++++++++++++++++++++++- lib/metadata/scoreProfileGeneric.json | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/front/src/views/rule.html b/front/src/views/rule.html index 9385be9..6ec11ab 100644 --- a/front/src/views/rule.html +++ b/front/src/views/rule.html @@ -150,6 +150,11 @@ +
+ + ({{offender.type}}) +
+
cached for {{offender.ttlWithUnit}} {{offender.unit}} diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index fc18c4d..75079f8 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -1130,6 +1130,35 @@ var policies = { "isAbnormalThreshold": 1, "hasOffenders": true }, + "assetsNotGzipped": { + "tool": "phantomas", + "label": "Not gzipped", + "message": "

This is the number of requests that should be compressed with gzip but aren't.

Gzip is a powerfull weight reducer and should be enabled on text-based assets in your server's configuration. Note that gzipping small files (< 1 KB) is arguable, and that some assets such as images should not be gzipped as they are already compressed. Here is a list of Content-Types that should be gzipped.

", + "isOkThreshold": 0, + "isBadThreshold": 12, + "isAbnormalThreshold": 20, + "hasOffenders": true, + "offendersTransformFn": function(offenders) { + return { + count: offenders.length, + list: offenders.map(function(offender) { + var parts = /^([^ ]*) \((.+)\)$/.exec(offender); + + if (!parts) { + debug('assetsNotGzipped offenders transform function error with "%s"', offender); + return { + parseError: offender + }; + } + + return { + file: parts[1], + type: parts[2] + }; + }) + }; + } + }, "closedConnections": { "tool": "phantomas", "label": "Connections closed", @@ -1250,7 +1279,6 @@ var policies = { domain: parts[1], requests: parseInt(parts[2]) }; - }) }; } diff --git a/lib/metadata/scoreProfileGeneric.json b/lib/metadata/scoreProfileGeneric.json index aeda814..841444e 100644 --- a/lib/metadata/scoreProfileGeneric.json +++ b/lib/metadata/scoreProfileGeneric.json @@ -95,6 +95,7 @@ "label": "Network", "policies": { "notFound": 2, + "assetsNotGzipped": 1.5, "closedConnections": 2, "multipleRequests": 2, "cachingNotSpecified": 1,