Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: Source/devtools/front_end/audits/AuditRules.js

Issue 1294473004: DevTools: Remove proxy caching audit. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/devtools/front_end/audits/AuditCategories.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 (this.hasResponseHeader(request, "Expires") || !!this.responseHeader Match(request, "Cache-Control", "max-age")); 740 (this.hasResponseHeader(request, "Expires") || !!this.responseHeader Match(request, "Cache-Control", "max-age"));
741 }, 741 },
742 742
743 /** 743 /**
744 * @param {!WebInspector.NetworkRequest} request 744 * @param {!WebInspector.NetworkRequest} request
745 * @return {boolean} 745 * @return {boolean}
746 */ 746 */
747 _isExplicitlyNonCacheable: function(request) 747 _isExplicitlyNonCacheable: function(request)
748 { 748 {
749 var hasExplicitExp = this.hasExplicitExpiration(request); 749 var hasExplicitExp = this.hasExplicitExpiration(request);
750 return !!this.responseHeaderMatch(request, "Cache-Control", "(no-cache|n o-store|must-revalidate)") || 750 return !!this.responseHeaderMatch(request, "Cache-Control", "(no-cache|n o-store)") ||
751 !!this.responseHeaderMatch(request, "Pragma", "no-cache") || 751 !!this.responseHeaderMatch(request, "Pragma", "no-cache") ||
752 (hasExplicitExp && !this.freshnessLifetimeGreaterThan(request, 0)) | | 752 (hasExplicitExp && !this.freshnessLifetimeGreaterThan(request, 0)) | |
753 (!hasExplicitExp && !!request.url && request.url.indexOf("?") >= 0) || 753 (!hasExplicitExp && !!request.url && request.url.indexOf("?") >= 0) ||
754 (!hasExplicitExp && !this.isCacheableResource(request)); 754 (!hasExplicitExp && !this.isCacheableResource(request));
755 }, 755 },
756 756
757 /** 757 /**
758 * @param {!WebInspector.NetworkRequest} request 758 * @param {!WebInspector.NetworkRequest} request
759 * @return {boolean} 759 * @return {boolean}
760 */ 760 */
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 !this.hasResponseHeader(request, "Set-Cookie") && 830 !this.hasResponseHeader(request, "Set-Cookie") &&
831 !this.freshnessLifetimeGreaterThan(request, 11 * WebInspector.AuditR ules.CacheControlRule.MillisPerMonth) && 831 !this.freshnessLifetimeGreaterThan(request, 11 * WebInspector.AuditR ules.CacheControlRule.MillisPerMonth) &&
832 this.freshnessLifetimeGreaterThan(request, WebInspector.AuditRules.C acheControlRule.MillisPerMonth); 832 this.freshnessLifetimeGreaterThan(request, WebInspector.AuditRules.C acheControlRule.MillisPerMonth);
833 }, 833 },
834 834
835 __proto__: WebInspector.AuditRules.CacheControlRule.prototype 835 __proto__: WebInspector.AuditRules.CacheControlRule.prototype
836 } 836 }
837 837
838 /** 838 /**
839 * @constructor 839 * @constructor
840 * @extends {WebInspector.AuditRules.CacheControlRule}
841 */
842 WebInspector.AuditRules.ProxyCacheControlRule = function() {
843 WebInspector.AuditRules.CacheControlRule.call(this, "http-proxycache", WebIn spector.UIString("Leverage proxy caching"));
844 }
845
846 WebInspector.AuditRules.ProxyCacheControlRule.prototype = {
847 runChecks: function(requests, result, callback)
848 {
849 this.execCheck(WebInspector.UIString("Resources with a \"?\" in the URL are not cached by most proxy caching servers:"),
850 this._questionMarkCheck, requests, result);
851 this.execCheck(WebInspector.UIString("Consider adding a \"Cache-Control: public\" header to the following resources:"),
852 this._publicCachingCheck, requests, result);
853 this.execCheck(WebInspector.UIString("The following publicly cacheable r esources contain a Set-Cookie header. This security vulnerability can cause cook ies to be shared by multiple users."),
854 this._setCookieCacheableCheck, requests, result);
855 },
856
857 _questionMarkCheck: function(request)
858 {
859 return request.url.indexOf("?") >= 0 && !this.hasResponseHeader(request, "Set-Cookie") && this.isPubliclyCacheable(request);
860 },
861
862 _publicCachingCheck: function(request)
863 {
864 return this.isCacheableResource(request) &&
865 !this.isCompressible(request) &&
866 !this.responseHeaderMatch(request, "Cache-Control", "public") &&
867 !this.hasResponseHeader(request, "Set-Cookie");
868 },
869
870 _setCookieCacheableCheck: function(request)
871 {
872 return this.hasResponseHeader(request, "Set-Cookie") && this.isPubliclyC acheable(request);
873 },
874
875 __proto__: WebInspector.AuditRules.CacheControlRule.prototype
876 }
877
878 /**
879 * @constructor
880 * @extends {WebInspector.AuditRule} 840 * @extends {WebInspector.AuditRule}
881 */ 841 */
882 WebInspector.AuditRules.ImageDimensionsRule = function() 842 WebInspector.AuditRules.ImageDimensionsRule = function()
883 { 843 {
884 WebInspector.AuditRule.call(this, "page-imagedims", WebInspector.UIString("S pecify image dimensions")); 844 WebInspector.AuditRule.call(this, "page-imagedims", WebInspector.UIString("S pecify image dimensions"));
885 } 845 }
886 846
887 WebInspector.AuditRules.ImageDimensionsRule.prototype = { 847 WebInspector.AuditRules.ImageDimensionsRule.prototype = {
888 /** 848 /**
889 * @override 849 * @override
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 result.violationCount = badUrls.length; 1647 result.violationCount = badUrls.length;
1688 }, 1648 },
1689 1649
1690 _collectorCallback: function(matchingResourceData, request, cookie) 1650 _collectorCallback: function(matchingResourceData, request, cookie)
1691 { 1651 {
1692 matchingResourceData[request.url] = (matchingResourceData[request.url] | | 0) + cookie.size(); 1652 matchingResourceData[request.url] = (matchingResourceData[request.url] | | 0) + cookie.size();
1693 }, 1653 },
1694 1654
1695 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype 1655 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype
1696 } 1656 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/audits/AuditCategories.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698