Skip to content

Commit c5ff8ee

Browse files
rmarxtunethewebgithub-actions[bot]
authored
HTTP 2024 Chapter (#3828)
* Initial tryout commit for HTTP chapter * First part of the HTTP 2024 chapter with images * Optimised images with calibre/image-actions * Update contributors * Standardise decimal places * Edits * Links * Fixes * alt-svc * More edits * Fix SQL names * Fix config * Fix contributors * First section of part 2 on resource hints v1 written * Fix preload queries * Finalizing part 2 writing. Finishing edits to part 1. * Optimised images with calibre/image-actions * Markup cleanups * Retake images * Edits * Editing pass Robin * Update contributor info for author * Nits * Add and update image/figure descriptions * Extra queries for Robin * Integrated new results from final 2 queries * Final final final final final tweaks --------- Co-authored-by: Barry Pollard <barrypollard@google.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 92358b3 commit c5ff8ee

24 files changed

Lines changed: 675 additions & 66 deletions

sql/2024/http/h3_switches.sql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#standardSQL
22
# Pages which had resources from domains with both h2 and h3 requests
3-
# Note this returns 0 rows at the moment
43
#
54

65
SELECT
@@ -26,14 +25,12 @@ GROUP BY
2625
date,
2726
client,
2827
page,
29-
url_host,
30-
protocol
28+
url_host
3129
HAVING
3230
h2_requests > 0 AND
3331
h3_requests > 0
3432
ORDER BY
3533
date,
3634
client,
3735
page,
38-
url_host,
39-
protocol
36+
url_host

sql/2024/http/h3_switches_pct.sql

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
WITH requests AS (
2+
SELECT DISTINCT
3+
date,
4+
client,
5+
page,
6+
NET.HOST(url) AS url_host,
7+
JSON_EXTRACT_SCALAR(summary, '$.respHttpVersion') AS protocol,
8+
resp_headers.value AS alt_svc
9+
FROM
10+
`httparchive.crawl.requests`
11+
JOIN
12+
UNNEST(response_headers) AS resp_headers ON LOWER(resp_headers.name) = 'alt-svc'
13+
WHERE
14+
date = '2024-06-01' AND
15+
is_root_page
16+
),
17+
18+
url_host_totals AS (
19+
SELECT
20+
date,
21+
client,
22+
url_host,
23+
COUNT(DISTINCT page) AS total_pages
24+
FROM
25+
requests
26+
WHERE
27+
alt_svc LIKE '%h3%' AND
28+
protocol IN ('HTTP/2', 'h2')
29+
GROUP BY
30+
date,
31+
client,
32+
url_host
33+
)
34+
35+
SELECT
36+
client,
37+
url_host,
38+
COUNT(DISTINCT page) AS switched_pages,
39+
total_pages,
40+
COUNT(DISTINCT page) / total_pages AS pct_pages,
41+
ARRAY_TO_STRING(ARRAY_AGG(DISTINCT page LIMIT 5), ', ') AS sample_urls
42+
FROM
43+
url_host_totals
44+
JOIN (
45+
SELECT
46+
date,
47+
client,
48+
page,
49+
url_host,
50+
COUNTIF(protocol IN ('HTTP/2', 'h2')) AS h2_requests,
51+
COUNTIF(protocol IN ('HTTP/3', 'h3', 'h3-29')) AS h3_requests
52+
FROM
53+
requests
54+
GROUP BY
55+
date,
56+
client,
57+
page,
58+
url_host
59+
HAVING
60+
h2_requests > 0 AND
61+
h3_requests > 0
62+
ORDER BY
63+
date,
64+
client,
65+
page,
66+
url_host
67+
)
68+
USING (date, client, url_host)
69+
GROUP BY
70+
client,
71+
url_host,
72+
total_pages
73+
HAVING
74+
switched_pages > 10
75+
ORDER BY
76+
switched_pages DESC,
77+
client,
78+
url_host
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
SELECT
2+
date,
3+
client,
4+
dns_https_or_svcb,
5+
CASE
6+
WHEN protocol IN ('HTTP/3', 'h3', 'h3-29') OR
7+
protocol IN ('HTTP/3', 'h3', 'h3-29') THEN 'h3_used'
8+
ELSE 'h3_not_used'
9+
END AS h3_used,
10+
CASE
11+
WHEN protocol IN ('HTTP/3', 'h3', 'h3-29') OR
12+
protocol IN ('HTTP/3', 'h3', 'h3-29') OR
13+
alt_svc LIKE '%h3=%' OR
14+
alt_svc LIKE '%h3-29=%' THEN 'h3_supported'
15+
ELSE 'h3_not_supported'
16+
END AS h3_supported,
17+
COUNT(DISTINCT page) AS num_pages,
18+
SUM(COUNT(DISTINCT page)) OVER (PARTITION BY date, client) AS total_pages,
19+
COUNT(DISTINCT page) / SUM(COUNT(DISTINCT page)) OVER (PARTITION BY date, client) AS pct_pages
20+
FROM (
21+
SELECT
22+
date,
23+
client,
24+
page,
25+
is_main_document,
26+
JSON_EXTRACT(p.payload, '$._origin_dns.https') != '[]' OR JSON_EXTRACT(p.payload, '$._origin_dns.svcb') != '[]' AS dns_https_or_svcb,
27+
JSON_EXTRACT_SCALAR(r.summary, '$.respHttpVersion') AS protocol,
28+
resp_headers.value AS alt_svc
29+
FROM
30+
`httparchive.all.pages` p
31+
JOIN
32+
`httparchive.all.requests` r
33+
USING (date, client, page, is_root_page)
34+
LEFT OUTER JOIN
35+
UNNEST(response_headers) AS resp_headers ON LOWER(resp_headers.name) = 'alt-svc'
36+
WHERE
37+
date = '2024-06-01' AND
38+
is_root_page AND
39+
is_main_document)
40+
GROUP BY
41+
date,
42+
client,
43+
dns_https_or_svcb,
44+
h3_used,
45+
h3_supported
46+
ORDER BY
47+
date,
48+
client,
49+
dns_https_or_svcb,
50+
h3_used,
51+
h3_supported

sql/2024/http/lcp_element_data_by_type.sql

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,6 @@ CREATE TEMP FUNCTION getLoadingClasses(attributes STRING) RETURNS STRING LANGUAG
4242
}
4343
''';
4444

45-
CREATE TEMPORARY FUNCTION getResourceHints(linkNodes STRING)
46-
RETURNS STRUCT<preload BOOLEAN, prefetch BOOLEAN, preconnect BOOLEAN, prerender BOOLEAN, `dns-prefetch` BOOLEAN, `modulepreload` BOOLEAN>
47-
LANGUAGE js AS '''
48-
var hints = ['preload', 'prefetch', 'preconnect', 'prerender', 'dns-prefetch', 'modulepreload'];
49-
try {
50-
var linkNodes = JSON.parse(linkNodes);
51-
return hints.reduce((results, hint) => {
52-
results[hint] = !!linkNodes.nodes.find(link => link.rel.toLowerCase() == hint);
53-
return results;
54-
}, {});
55-
} catch (e) {
56-
return hints.reduce((results, hint) => {
57-
results[hint] = false;
58-
return results;
59-
}, {});
60-
}
61-
''';
62-
6345
WITH lcp_stats AS (
6446
SELECT
6547
client,
@@ -77,7 +59,7 @@ WITH lcp_stats AS (
7759
getFetchPriorityAttr(JSON_EXTRACT(custom_metrics, '$.performance.lcp_elem_stats.attributes')) AS fetchPriority,
7860
LOWER(JSON_EXTRACT_SCALAR(custom_metrics, '$.performance.lcp_resource.initialPriority')) AS initalPriority,
7961
LOWER(JSON_EXTRACT_SCALAR(custom_metrics, '$.performance.lcp_resource.priority')) AS priority,
80-
getResourceHints(JSON_EXTRACT(custom_metrics, '$.almanac.link-nodes')) AS hints
62+
CAST(JSON_EXTRACT(custom_metrics, '$.performance.is_lcp_preloaded') AS BOOL) AS preloaded
8163
FROM
8264
`httparchive.all.pages`
8365
WHERE
@@ -116,8 +98,8 @@ SELECT
11698
COUNTIF(initalPriority = 'high') / COUNT(DISTINCT page) AS pct_inital_priority_high,
11799
COUNTIF(initalPriority = 'high' AND fetchPriority = 'high') / COUNT(DISTINCT page) AS pct_inital_priority_high_and_fetchpriority,
118100
COUNTIF(loading = 'lazy' AND fetchPriority = 'high') / COUNT(DISTINCT page) AS pct_native_lazyload_and_fetch_priority,
119-
COUNTIF(hints.preload) AS preload,
120-
COUNTIF(hints.preload) / COUNT(DISTINCT page) AS pct_preload
101+
COUNTIF(preloaded) AS preload,
102+
COUNTIF(preloaded) / COUNT(DISTINCT page) AS pct_preload
121103
FROM
122104
lcp_stats
123105
JOIN (

sql/2024/http/lcp_element_data_with_urls.sql

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,6 @@ CREATE TEMP FUNCTION getLoadingClasses(attributes STRING) RETURNS STRING LANGUAG
4242
}
4343
''';
4444

45-
CREATE TEMPORARY FUNCTION getResourceHints(linkNodes STRING)
46-
RETURNS STRUCT<preload BOOLEAN, prefetch BOOLEAN, preconnect BOOLEAN, prerender BOOLEAN, `dns-prefetch` BOOLEAN, `modulepreload` BOOLEAN>
47-
LANGUAGE js AS '''
48-
var hints = ['preload', 'prefetch', 'preconnect', 'prerender', 'dns-prefetch', 'modulepreload'];
49-
try {
50-
var linkNodes = JSON.parse(linkNodes);
51-
return hints.reduce((results, hint) => {
52-
results[hint] = !!linkNodes.nodes.find(link => link.rel.toLowerCase() == hint);
53-
return results;
54-
}, {});
55-
} catch (e) {
56-
return hints.reduce((results, hint) => {
57-
results[hint] = false;
58-
return results;
59-
}, {});
60-
}
61-
''';
62-
6345
WITH lcp_stats AS (
6446
SELECT
6547
client,
@@ -77,7 +59,7 @@ WITH lcp_stats AS (
7759
getFetchPriorityAttr(JSON_EXTRACT(custom_metrics, '$.performance.lcp_elem_stats.attributes')) AS fetchPriority,
7860
LOWER(JSON_EXTRACT_SCALAR(custom_metrics, '$.performance.lcp_resource.initialPriority')) AS initalPriority,
7961
LOWER(JSON_EXTRACT_SCALAR(custom_metrics, '$.performance.lcp_resource.priority')) AS priority,
80-
getResourceHints(JSON_EXTRACT(custom_metrics, '$.almanac.link-nodes')) AS hints
62+
CAST(JSON_EXTRACT(custom_metrics, '$.performance.is_lcp_preloaded') AS BOOL) AS preloaded
8163
FROM
8264
`httparchive.all.pages`
8365
WHERE
@@ -117,8 +99,8 @@ SELECT
11799
COUNTIF(initalPriority = 'high') / COUNT(DISTINCT page) AS pct_inital_priority_high,
118100
COUNTIF(initalPriority = 'high' AND fetchPriority = 'high') / COUNT(DISTINCT page) AS pct_inital_priority_high_and_fetchpriority,
119101
COUNTIF(loading = 'lazy' AND fetchPriority = 'high') / COUNT(DISTINCT page) AS pct_native_lazyload_and_fetch_priority,
120-
COUNTIF(hints.preload) AS preload,
121-
COUNTIF(hints.preload) / COUNT(DISTINCT page) AS pct_preload
102+
COUNTIF(preloaded) AS preload,
103+
COUNTIF(preloaded) / COUNT(DISTINCT page) AS pct_preload
122104
FROM
123105
lcp_stats
124106
JOIN (

src/config/2024.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@
157157
"part": "IV",
158158
"chapter_number": "20",
159159
"title": "HTTP",
160-
"slug": "http",
161-
"todo": true
160+
"slug": "http"
162161
},
163162
{
164163
"part": "IV",

src/config/contributors.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,10 @@
676676
"reviewers"
677677
],
678678
"2024": [
679+
"analysts",
680+
"committee",
679681
"developers",
680682
"editors",
681-
"committee",
682683
"reviewers"
683684
]
684685
},
@@ -1026,13 +1027,15 @@
10261027
"website": "https://chrisadams.me.uk"
10271028
},
10281029
"ChrisBeeti": {
1030+
"avatar_url": "32492572",
10291031
"github": "ChrisBeeti",
10301032
"name": "Chris Böttger",
10311033
"teams": {
10321034
"2024": [
10331035
"analysts",
10341036
"authors",
1035-
"committee"
1037+
"committee",
1038+
"reviewers"
10361039
]
10371040
}
10381041
},
@@ -3856,6 +3859,8 @@
38563859
"rmarx": {
38573860
"avatar_url": "2240689",
38583861
"github": "rmarx",
3862+
"linkedin": "rmarx",
3863+
"bluesky": "programmingart.bsky.social",
38593864
"name": "Robin Marx",
38603865
"teams": {
38613866
"2019": [
@@ -3869,6 +3874,9 @@
38693874
],
38703875
"2022": [
38713876
"reviewers"
3877+
],
3878+
"2024": [
3879+
"authors"
38723880
]
38733881
},
38743882
"twitter": "programmingart",

src/config/last_updated.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,8 @@
787787
"hash": "0972e7e4c8b572e58aa8dead2b4d7e13"
788788
},
789789
"en/2024/chapters/http.html": {
790-
"date_published": "2024-11-11T00:00:00.000Z",
791-
"date_modified": "2024-11-16T00:00:00.000Z",
790+
"date_published": "2024-12-10T00:00:00.000Z",
791+
"date_modified": "2024-12-10T00:00:00.000Z",
792792
"hash": "aa71b4be8ab44d4379d6ba6c8fbc78b7"
793793
},
794794
"en/2024/chapters/jamstack.html": {

0 commit comments

Comments
 (0)