You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sql/2025/sustainability/cache_header_usage.sql
+81-36Lines changed: 81 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -2,49 +2,94 @@
2
2
# The distribution of cache header adoption on websites by client.
3
3
4
4
SELECT
5
-
client,
6
-
COUNT(0) AS total_requests,
7
-
8
-
COUNTIF(uses_cache_control) AS total_using_cache_control,
9
-
COUNTIF(uses_max_age) AS total_using_max_age,
10
-
COUNTIF(uses_expires) AS total_using_expires,
11
-
COUNTIF(uses_max_age AND uses_expires) AS total_using_max_age_and_expires,
12
-
COUNTIF(uses_cache_control AND uses_expires) AS total_using_both_cc_and_expires,
13
-
COUNTIF(NOT uses_cache_control AND NOT uses_expires) AS total_using_neither_cc_and_expires,
14
-
COUNTIF(uses_cache_control AND NOT uses_expires) AS total_using_only_cache_control,
15
-
COUNTIF(NOT uses_cache_control AND uses_expires) AS total_using_only_expires,
16
-
17
-
COUNTIF(uses_cache_control) /COUNT(0) AS pct_cache_control,
18
-
COUNTIF(uses_max_age) /COUNT(0) AS pct_using_max_age,
19
-
COUNTIF(uses_expires) /COUNT(0) AS pct_using_expires,
20
-
COUNTIF(uses_max_age AND uses_expires) /COUNT(0) AS pct_using_max_age_and_expires,
21
-
COUNTIF(uses_cache_control AND uses_expires) /COUNT(0) AS pct_using_both_cc_and_expires,
22
-
COUNTIF(NOT uses_cache_control AND NOT uses_expires) /COUNT(0) AS pct_using_neither_cc_nor_expires,
23
-
COUNTIF(uses_cache_control AND NOT uses_expires) /COUNT(0) AS pct_using_only_cache_control,
24
-
COUNTIF(NOT uses_cache_control AND uses_expires) /COUNT(0) AS pct_using_only_expires
5
+
client,
6
+
COUNT(*) AS total_requests,
7
+
8
+
COUNTIF(uses_cache_control) AS total_using_cache_control,
9
+
COUNTIF(uses_max_age) AS total_using_max_age,
10
+
COUNTIF(uses_expires) AS total_using_expires,
11
+
COUNTIF(uses_max_age AND uses_expires) AS total_using_max_age_and_expires,
12
+
COUNTIF(
13
+
uses_cache_control AND uses_expires
14
+
) AS total_using_both_cc_and_expires,
15
+
COUNTIF(
16
+
NOT uses_cache_control AND NOT uses_expires
17
+
) AS total_using_neither_cc_and_expires,
18
+
COUNTIF(
19
+
uses_cache_control AND NOT uses_expires
20
+
) AS total_using_only_cache_control,
21
+
COUNTIF(
22
+
NOT uses_cache_control AND uses_expires
23
+
) AS total_using_only_expires,
24
+
25
+
COUNTIF(uses_cache_control) /COUNT(*) AS pct_cache_control,
26
+
COUNTIF(uses_max_age) /COUNT(*) AS pct_using_max_age,
27
+
COUNTIF(uses_expires) /COUNT(*) AS pct_using_expires,
28
+
COUNTIF(
29
+
uses_max_age AND uses_expires
30
+
) /COUNT(*) AS pct_using_max_age_and_expires,
31
+
COUNTIF(
32
+
uses_cache_control AND uses_expires
33
+
) /COUNT(*) AS pct_using_both_cc_and_expires,
34
+
COUNTIF(
35
+
NOT uses_cache_control AND NOT uses_expires
36
+
) /COUNT(*) AS pct_using_neither_cc_nor_expires,
37
+
COUNTIF(
38
+
uses_cache_control AND NOT uses_expires
39
+
) /COUNT(*) AS pct_using_only_cache_control,
40
+
COUNTIF(
41
+
NOT uses_cache_control AND uses_expires
42
+
) /COUNT(*) AS pct_using_only_expires
25
43
26
44
FROM (
27
-
SELECT
28
-
client,
45
+
SELECT
46
+
client,
29
47
30
-
JSON_EXTRACT_SCALAR(summary, '$.resp_expires') IS NOT NULLANDTRIM(JSON_EXTRACT_SCALAR(summary, '$.resp_expires')) !=''AS uses_expires,
31
-
JSON_EXTRACT_SCALAR(summary, '$.resp_cache_control') IS NOT NULLANDTRIM(JSON_EXTRACT_SCALAR(summary, '$.resp_cache_control')) !=''AS uses_cache_control,
32
-
REGEXP_CONTAINS(JSON_EXTRACT_SCALAR(summary, '$.resp_cache_control'), r'(?i)max-age\s*=\s*[0-9]+') AS uses_max_age,
JSON_EXTRACT_SCALAR(summary, '$.resp_etag') IS NULLORTRIM(JSON_EXTRACT_SCALAR(summary, '$.resp_etag')) =''AS uses_no_etag,
35
-
JSON_EXTRACT_SCALAR(summary, '$.resp_etag') IS NOT NULLANDTRIM(JSON_EXTRACT_SCALAR(summary, '$.resp_etag')) !=''AS uses_etag,
36
-
JSON_EXTRACT_SCALAR(summary, '$.resp_last_modified') IS NOT NULLANDTRIM(JSON_EXTRACT_SCALAR(summary, '$.resp_last_modified')) !=''AS uses_last_modified,
0 commit comments