{"action":"created","comment":{"url":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/comments/156432848","pull_request_review_id":82907799,"id":156432848,"diff_hunk":"@@ -0,0 +1,207 @@\n+# HTTP Cache (`http-cache`)\n+\n+`http-cache` verifies that the page and all its resources follow a good,\n+sustainable caching strategy.\n+\n+## Why is this important?\n+\n+You can easily improve the performance of your website by having a\n+right caching strategy:\n+\n+* Shorter load times\n+* Less bandwidth required\n+* Reduce server costs\n+* Have a predictable behavior across browsers\n+\n+Currently about ~50% of resources on the web can't be cached due to\n+their configuration:\n+\n+![Cacheable Resources][maxage0 image]\n+\n+[Source: http archive][maxage0]\n+\n+## What does the rule check?\n+\n+This rule checks the configuration of the `cache-control` header to\n+validate that the page and resources have a good caching strategy:\n+\n+* all requests have a `Cache-Control` header, otherwise the behavior\n+  can change from browser to browser\n+* main page should have a short cache (<= 3 minutes) or not cache at all\n+* static resources such as JavaScript, CSS, images, etc.:\n+  * have a long expiry value (>= 1 year)\n+  * use the `immutable` directive\n+  * follow some kind of revving format based on filename and not parameter\n+    see [problems with proxys][revving files]\n+\n+The built-in regular expressions for file revving are:\n+\n+```regexp\n+/\\w+\\.\\w+\\.\\w{1,3}$/i,\n+/\\w+-\\w+\\.\\w{1,3}$/i\n+```\n+\n+This will match urls like the following:\n+\n+```text\n+https://example.com/assets/script.12345.js\n+https://example.com/assets/styles-12345.css\n+```\n+\n+## Can the rule be configured?\n+\n+Yes, you can configure:\n+\n+* the `max-age` values for the page and resources\n+* the regular expressions used to know if the file is immutable or not\n+\n+### `max-age`\n+\n+By default the recommended value for the page is `Cache-Control: no-cache`\n+or a `max-age` equal or less to 3 minutes. For the resources `max-age` should\n+be greater or equal to 1 year. You can change this as follows:\n+\n+```json\n+\"http-cache\": [\"error\", {\n+    \"maxAgeTarget\": 300, // 5 minutes in seconds\n+    \"maxAgeResource\": 1576800 // 6 months in seconds\n+}]\n+```\n+\n+### Custom regular expressions for revving files\n+\n+If none on the built-in regular expressions work for your use case, you\n+can provide your own via the `revvingPatterns` property. This property\n+accepts an `Array` of escaped `RegExp`:\n+\n+```json\n+\"http-cache\": [\"error\", {\n+    \"revvingPatterns\": [\"\\\\/\\\\d+\\\\/\\\\w+\\\\.\\\\w{1,3}\"]","path":"docs/user-guide/rules/http-cache.md","position":79,"original_position":79,"commit_id":"3485fc0d4a698ed4c137f561dc42532a40887bec","original_commit_id":"3485fc0d4a698ed4c137f561dc42532a40887bec","user":{"login":"alrra","id":1223565,"avatar_url":"https://avatars1.githubusercontent.com/u/1223565?v=4","gravatar_id":"","url":"https://api.github.com/users/alrra","html_url":"https://github.com/alrra","followers_url":"https://api.github.com/users/alrra/followers","following_url":"https://api.github.com/users/alrra/following{/other_user}","gists_url":"https://api.github.com/users/alrra/gists{/gist_id}","starred_url":"https://api.github.com/users/alrra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alrra/subscriptions","organizations_url":"https://api.github.com/users/alrra/orgs","repos_url":"https://api.github.com/users/alrra/repos","events_url":"https://api.github.com/users/alrra/events{/privacy}","received_events_url":"https://api.github.com/users/alrra/received_events","type":"User","site_admin":false},"body":"This needs to be updated.","created_at":"2017-12-12T17:08:56Z","updated_at":"2017-12-12T17:25:47Z","html_url":"https://github.com/sonarwhal/sonarwhal/pull/708#discussion_r156432848","pull_request_url":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/comments/156432848"},"html":{"href":"https://github.com/sonarwhal/sonarwhal/pull/708#discussion_r156432848"},"pull_request":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708"}}},"pull_request":{"url":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708","id":157711070,"html_url":"https://github.com/sonarwhal/sonarwhal/pull/708","diff_url":"https://github.com/sonarwhal/sonarwhal/pull/708.diff","patch_url":"https://github.com/sonarwhal/sonarwhal/pull/708.patch","issue_url":"https://api.github.com/repos/sonarwhal/sonarwhal/issues/708","number":708,"state":"open","locked":false,"title":"New: Add `http-cache` rule","user":{"login":"molant","id":606594,"avatar_url":"https://avatars0.githubusercontent.com/u/606594?v=4","gravatar_id":"","url":"https://api.github.com/users/molant","html_url":"https://github.com/molant","followers_url":"https://api.github.com/users/molant/followers","following_url":"https://api.github.com/users/molant/following{/other_user}","gists_url":"https://api.github.com/users/molant/gists{/gist_id}","starred_url":"https://api.github.com/users/molant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/molant/subscriptions","organizations_url":"https://api.github.com/users/molant/orgs","repos_url":"https://api.github.com/users/molant/repos","events_url":"https://api.github.com/users/molant/events{/privacy}","received_events_url":"https://api.github.com/users/molant/received_events","type":"User","site_admin":false},"body":"<!--\r\n\r\nRead our pull request guide:\r\nhttps://sonarwhal.com/docs/contributor-guide/contributing/pull-requests/\r\n\r\nFor the following items put an \"x\" between the square brackets\r\n(i.e. [x]) if you completed the associated item.\r\n\r\n-->\r\n\r\n## Pull request checklist\r\n\r\nMake sure you:\r\n\r\n- [x] Signed the [Contributor License Agreement](https://cla.js.foundation/sonarwhal/sonarwhal)\r\n- [x] Followed the [commit message guidelines](https://sonarwhal.com/docs/contributor-guide/contributing/pull-requests/#commitmessages)\r\n\r\nFor non-trivial changes, please make sure you also:\r\n\r\n- [x] Added/Updated related documentation.\r\n- [x] Added/Updated related tests.\r\n\r\n## Short description of the change(s)\r\n\r\nNew `http-cache` rule that validates if the site uses a good and\r\nsustainable caching strategy.\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n\r\nFix: #142\r\n\r\n\r\n<!--\r\n\r\nIf this is a non-trivial change, include information such as what\r\nbenefits this change brings as well as possible drawbacks.\r\n\r\nIf this fixes an existing issue, include the relavant issue number(s).\r\n\r\nThank you for taking the time to open this PR!\r\n\r\n-->\r\n","created_at":"2017-12-12T00:56:12Z","updated_at":"2017-12-12T17:25:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44a6461236abdf26968db6633c565babab469e90","assignee":null,"assignees":[],"requested_reviewers":[{"login":"austinkelleher","id":3771924,"avatar_url":"https://avatars0.githubusercontent.com/u/3771924?v=4","gravatar_id":"","url":"https://api.github.com/users/austinkelleher","html_url":"https://github.com/austinkelleher","followers_url":"https://api.github.com/users/austinkelleher/followers","following_url":"https://api.github.com/users/austinkelleher/following{/other_user}","gists_url":"https://api.github.com/users/austinkelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/austinkelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/austinkelleher/subscriptions","organizations_url":"https://api.github.com/users/austinkelleher/orgs","repos_url":"https://api.github.com/users/austinkelleher/repos","events_url":"https://api.github.com/users/austinkelleher/events{/privacy}","received_events_url":"https://api.github.com/users/austinkelleher/received_events","type":"User","site_admin":false},{"login":"qzhou1607","id":20218531,"avatar_url":"https://avatars1.githubusercontent.com/u/20218531?v=4","gravatar_id":"","url":"https://api.github.com/users/qzhou1607","html_url":"https://github.com/qzhou1607","followers_url":"https://api.github.com/users/qzhou1607/followers","following_url":"https://api.github.com/users/qzhou1607/following{/other_user}","gists_url":"https://api.github.com/users/qzhou1607/gists{/gist_id}","starred_url":"https://api.github.com/users/qzhou1607/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qzhou1607/subscriptions","organizations_url":"https://api.github.com/users/qzhou1607/orgs","repos_url":"https://api.github.com/users/qzhou1607/repos","events_url":"https://api.github.com/users/qzhou1607/events{/privacy}","received_events_url":"https://api.github.com/users/qzhou1607/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708/commits","review_comments_url":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708/comments","review_comment_url":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sonarwhal/sonarwhal/issues/708/comments","statuses_url":"https://api.github.com/repos/sonarwhal/sonarwhal/statuses/3485fc0d4a698ed4c137f561dc42532a40887bec","head":{"label":"molant:cache-control","ref":"cache-control","sha":"3485fc0d4a698ed4c137f561dc42532a40887bec","user":{"login":"molant","id":606594,"avatar_url":"https://avatars0.githubusercontent.com/u/606594?v=4","gravatar_id":"","url":"https://api.github.com/users/molant","html_url":"https://github.com/molant","followers_url":"https://api.github.com/users/molant/followers","following_url":"https://api.github.com/users/molant/following{/other_user}","gists_url":"https://api.github.com/users/molant/gists{/gist_id}","starred_url":"https://api.github.com/users/molant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/molant/subscriptions","organizations_url":"https://api.github.com/users/molant/orgs","repos_url":"https://api.github.com/users/molant/repos","events_url":"https://api.github.com/users/molant/events{/privacy}","received_events_url":"https://api.github.com/users/molant/received_events","type":"User","site_admin":false},"repo":{"id":94958400,"name":"sonar","full_name":"molant/sonar","owner":{"login":"molant","id":606594,"avatar_url":"https://avatars0.githubusercontent.com/u/606594?v=4","gravatar_id":"","url":"https://api.github.com/users/molant","html_url":"https://github.com/molant","followers_url":"https://api.github.com/users/molant/followers","following_url":"https://api.github.com/users/molant/following{/other_user}","gists_url":"https://api.github.com/users/molant/gists{/gist_id}","starred_url":"https://api.github.com/users/molant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/molant/subscriptions","organizations_url":"https://api.github.com/users/molant/orgs","repos_url":"https://api.github.com/users/molant/repos","events_url":"https://api.github.com/users/molant/events{/privacy}","received_events_url":"https://api.github.com/users/molant/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/molant/sonar","description":null,"fork":true,"url":"https://api.github.com/repos/molant/sonar","forks_url":"https://api.github.com/repos/molant/sonar/forks","keys_url":"https://api.github.com/repos/molant/sonar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/molant/sonar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/molant/sonar/teams","hooks_url":"https://api.github.com/repos/molant/sonar/hooks","issue_events_url":"https://api.github.com/repos/molant/sonar/issues/events{/number}","events_url":"https://api.github.com/repos/molant/sonar/events","assignees_url":"https://api.github.com/repos/molant/sonar/assignees{/user}","branches_url":"https://api.github.com/repos/molant/sonar/branches{/branch}","tags_url":"https://api.github.com/repos/molant/sonar/tags","blobs_url":"https://api.github.com/repos/molant/sonar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/molant/sonar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/molant/sonar/git/refs{/sha}","trees_url":"https://api.github.com/repos/molant/sonar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/molant/sonar/statuses/{sha}","languages_url":"https://api.github.com/repos/molant/sonar/languages","stargazers_url":"https://api.github.com/repos/molant/sonar/stargazers","contributors_url":"https://api.github.com/repos/molant/sonar/contributors","subscribers_url":"https://api.github.com/repos/molant/sonar/subscribers","subscription_url":"https://api.github.com/repos/molant/sonar/subscription","commits_url":"https://api.github.com/repos/molant/sonar/commits{/sha}","git_commits_url":"https://api.github.com/repos/molant/sonar/git/commits{/sha}","comments_url":"https://api.github.com/repos/molant/sonar/comments{/number}","issue_comment_url":"https://api.github.com/repos/molant/sonar/issues/comments{/number}","contents_url":"https://api.github.com/repos/molant/sonar/contents/{+path}","compare_url":"https://api.github.com/repos/molant/sonar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/molant/sonar/merges","archive_url":"https://api.github.com/repos/molant/sonar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/molant/sonar/downloads","issues_url":"https://api.github.com/repos/molant/sonar/issues{/number}","pulls_url":"https://api.github.com/repos/molant/sonar/pulls{/number}","milestones_url":"https://api.github.com/repos/molant/sonar/milestones{/number}","notifications_url":"https://api.github.com/repos/molant/sonar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/molant/sonar/labels{/name}","releases_url":"https://api.github.com/repos/molant/sonar/releases{/id}","deployments_url":"https://api.github.com/repos/molant/sonar/deployments","created_at":"2017-06-21T03:20:07Z","updated_at":"2017-06-21T03:20:09Z","pushed_at":"2017-12-12T16:51:24Z","git_url":"git://github.com/molant/sonar.git","ssh_url":"git@github.com:molant/sonar.git","clone_url":"https://github.com/molant/sonar.git","svn_url":"https://github.com/molant/sonar","homepage":"https://sonarwhal.com/","size":3673,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sonarwhal:master","ref":"master","sha":"0a9657642b40321ce287bca7c0ac9e62d5f5c72b","user":{"login":"sonarwhal","id":25042266,"avatar_url":"https://avatars0.githubusercontent.com/u/25042266?v=4","gravatar_id":"","url":"https://api.github.com/users/sonarwhal","html_url":"https://github.com/sonarwhal","followers_url":"https://api.github.com/users/sonarwhal/followers","following_url":"https://api.github.com/users/sonarwhal/following{/other_user}","gists_url":"https://api.github.com/users/sonarwhal/gists{/gist_id}","starred_url":"https://api.github.com/users/sonarwhal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonarwhal/subscriptions","organizations_url":"https://api.github.com/users/sonarwhal/orgs","repos_url":"https://api.github.com/users/sonarwhal/repos","events_url":"https://api.github.com/users/sonarwhal/events{/privacy}","received_events_url":"https://api.github.com/users/sonarwhal/received_events","type":"Organization","site_admin":false},"repo":{"id":82211360,"name":"sonarwhal","full_name":"sonarwhal/sonarwhal","owner":{"login":"sonarwhal","id":25042266,"avatar_url":"https://avatars0.githubusercontent.com/u/25042266?v=4","gravatar_id":"","url":"https://api.github.com/users/sonarwhal","html_url":"https://github.com/sonarwhal","followers_url":"https://api.github.com/users/sonarwhal/followers","following_url":"https://api.github.com/users/sonarwhal/following{/other_user}","gists_url":"https://api.github.com/users/sonarwhal/gists{/gist_id}","starred_url":"https://api.github.com/users/sonarwhal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonarwhal/subscriptions","organizations_url":"https://api.github.com/users/sonarwhal/orgs","repos_url":"https://api.github.com/users/sonarwhal/repos","events_url":"https://api.github.com/users/sonarwhal/events{/privacy}","received_events_url":"https://api.github.com/users/sonarwhal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sonarwhal/sonarwhal","description":"A linting tool for the web","fork":false,"url":"https://api.github.com/repos/sonarwhal/sonarwhal","forks_url":"https://api.github.com/repos/sonarwhal/sonarwhal/forks","keys_url":"https://api.github.com/repos/sonarwhal/sonarwhal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sonarwhal/sonarwhal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sonarwhal/sonarwhal/teams","hooks_url":"https://api.github.com/repos/sonarwhal/sonarwhal/hooks","issue_events_url":"https://api.github.com/repos/sonarwhal/sonarwhal/issues/events{/number}","events_url":"https://api.github.com/repos/sonarwhal/sonarwhal/events","assignees_url":"https://api.github.com/repos/sonarwhal/sonarwhal/assignees{/user}","branches_url":"https://api.github.com/repos/sonarwhal/sonarwhal/branches{/branch}","tags_url":"https://api.github.com/repos/sonarwhal/sonarwhal/tags","blobs_url":"https://api.github.com/repos/sonarwhal/sonarwhal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sonarwhal/sonarwhal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sonarwhal/sonarwhal/git/refs{/sha}","trees_url":"https://api.github.com/repos/sonarwhal/sonarwhal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sonarwhal/sonarwhal/statuses/{sha}","languages_url":"https://api.github.com/repos/sonarwhal/sonarwhal/languages","stargazers_url":"https://api.github.com/repos/sonarwhal/sonarwhal/stargazers","contributors_url":"https://api.github.com/repos/sonarwhal/sonarwhal/contributors","subscribers_url":"https://api.github.com/repos/sonarwhal/sonarwhal/subscribers","subscription_url":"https://api.github.com/repos/sonarwhal/sonarwhal/subscription","commits_url":"https://api.github.com/repos/sonarwhal/sonarwhal/commits{/sha}","git_commits_url":"https://api.github.com/repos/sonarwhal/sonarwhal/git/commits{/sha}","comments_url":"https://api.github.com/repos/sonarwhal/sonarwhal/comments{/number}","issue_comment_url":"https://api.github.com/repos/sonarwhal/sonarwhal/issues/comments{/number}","contents_url":"https://api.github.com/repos/sonarwhal/sonarwhal/contents/{+path}","compare_url":"https://api.github.com/repos/sonarwhal/sonarwhal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sonarwhal/sonarwhal/merges","archive_url":"https://api.github.com/repos/sonarwhal/sonarwhal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sonarwhal/sonarwhal/downloads","issues_url":"https://api.github.com/repos/sonarwhal/sonarwhal/issues{/number}","pulls_url":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls{/number}","milestones_url":"https://api.github.com/repos/sonarwhal/sonarwhal/milestones{/number}","notifications_url":"https://api.github.com/repos/sonarwhal/sonarwhal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sonarwhal/sonarwhal/labels{/name}","releases_url":"https://api.github.com/repos/sonarwhal/sonarwhal/releases{/id}","deployments_url":"https://api.github.com/repos/sonarwhal/sonarwhal/deployments","created_at":"2017-02-16T18:15:31Z","updated_at":"2017-12-12T13:26:09Z","pushed_at":"2017-12-12T17:01:49Z","git_url":"git://github.com/sonarwhal/sonarwhal.git","ssh_url":"git@github.com:sonarwhal/sonarwhal.git","clone_url":"https://github.com/sonarwhal/sonarwhal.git","svn_url":"https://github.com/sonarwhal/sonarwhal","homepage":"https://sonarwhal.com/","size":3818,"stargazers_count":1156,"watchers_count":1156,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":81,"mirror_url":null,"archived":false,"open_issues_count":84,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":81,"open_issues":84,"watchers":1156,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708"},"html":{"href":"https://github.com/sonarwhal/sonarwhal/pull/708"},"issue":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/issues/708"},"comments":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/issues/708/comments"},"review_comments":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708/comments"},"review_comment":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/pulls/708/commits"},"statuses":{"href":"https://api.github.com/repos/sonarwhal/sonarwhal/statuses/3485fc0d4a698ed4c137f561dc42532a40887bec"}},"author_association":"OWNER"}}
{"actor":{"display_login":"alrra"}}