Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: filter out blob urls more often #8724

Merged
merged 2 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ class CacheHeaders extends Audit {
NetworkRequest.TYPES.Stylesheet,
]);

const resourceUrl = record.url;
// It's not a request loaded over the network, caching makes no sense
if (URL.NON_NETWORK_PROTOCOLS.includes(record.protocol)) return false;

return (
CACHEABLE_STATUS_CODES.has(record.statusCode) &&
STATIC_RESOURCE_TYPES.has(record.resourceType || 'Other') &&
!resourceUrl.includes('data:')
STATIC_RESOURCE_TYPES.has(record.resourceType || 'Other')
);
}

Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/font-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class FontDisplay extends Audit {
.filter(record => !passingFontURLs.has(record.url))
// ...and that aren't data URLs, the blocking concern doesn't really apply
.filter(record => !/^data:/.test(record.url))
.filter(record => !/^blob:/.test(record.url))
.map(record => {
// In reality the end time should be calculated with paint time included
// all browsers wait 3000ms to block text so we make sure 3000 is our max wasted time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function collectTagsThatBlockFirstPaint() {
!scriptTag.hasAttribute('async') &&
!scriptTag.hasAttribute('defer') &&
!/^data:/.test(scriptTag.src) &&
!/^blob:/.test(scriptTag.src) &&
scriptTag.getAttribute('type') !== 'module'
);
} else if (tag.tagName === 'LINK') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function networkRecord(options = {}) {
statusCode: options.statusCode || 200,
resourceType: options.resourceType || NetworkRequest.TYPES.Script,
transferSize: options.transferSize || 10000,
protocol: options.protocol || 'http/1.1',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super confusing that protocol on devtools isn't new URL().protocol 😩

responseHeaders: headers,
};
}
Expand Down Expand Up @@ -207,7 +208,8 @@ describe('Cache headers audit', () => {
const networkRecords = [
networkRecord({statusCode: 500}),
networkRecord({url: 'https://example.com/dynamic.js?userId=crazy', transferSize: 10}),
networkRecord({url: 'data:image/jpeg;base64,what'}),
networkRecord({url: 'data:image/jpeg;base64,what', protocol: 'data'}),
networkRecord({url: 'blob:http://example.com/ca6df701-9c67-49fd-a787', protocol: 'blob'}),
networkRecord({resourceType: NetworkRequest.TYPES.XHR}),
];

Expand Down
11 changes: 2 additions & 9 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@
"score": 0.58,
"scoreDisplayMode": "numeric",
"numericValue": 103455,
"displayValue": "11 resources found",
"displayValue": "10 resources found",
"details": {
"type": "table",
"headings": [
Expand Down Expand Up @@ -2003,13 +2003,6 @@
"cacheHitProbability": 0,
"totalBytes": 144,
"wastedBytes": 144
},
{
"url": "blob:http://localhost:10200/ae0eac03-ab9b-4a6a-b299-f5212153e277",
"cacheLifetimeMs": 0,
"cacheHitProbability": 0,
"totalBytes": 0,
"wastedBytes": 0
}
],
"summary": {
Expand Down Expand Up @@ -5092,7 +5085,7 @@
"lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js | displayValue": [
{
"values": {
"itemCount": 11
"itemCount": 10
},
"path": "audits[uses-long-cache-ttl].displayValue"
}
Expand Down
9 changes: 1 addition & 8 deletions proto/sample_v2_round_trip.json
Original file line number Diff line number Diff line change
Expand Up @@ -2659,21 +2659,14 @@
"totalBytes": 144.0,
"url": "http://localhost:10200/dobetterweb/empty_module.js?delay=500",
"wastedBytes": 144.0
},
{
"cacheHitProbability": 0.0,
"cacheLifetimeMs": 0.0,
"totalBytes": 0.0,
"url": "blob:http://localhost:10200/ae0eac03-ab9b-4a6a-b299-f5212153e277",
"wastedBytes": 0.0
}
],
"summary": {
"wastedBytes": 103455.0
},
"type": "table"
},
"displayValue": "11 resources found",
"displayValue": "10 resources found",
"id": "uses-long-cache-ttl",
"numericValue": 103455.0,
"score": 0.58,
Expand Down