SELECT type, compressed, resource_count, megabytes, type_ratio,
ROUND(total_ratio*100) as total_ratio
FROM (
SELECT type, compressed, resource_count, megabytes,
ROUND(type_ratio*100) as type_ratio,
RATIO_TO_REPORT(resource_count) OVER () as total_ratio
FROM (
SELECT type, compressed,
ROUND(SUM(respSize/(1024*1024))) as megabytes,
COUNT(*) as resource_count,
RATIO_TO_REPORT(resource_count) OVER (PARTITION BY type) as type_ratio
FROM (
SELECT respSize,
REGEXP_EXTRACT(LOWER(resp_content_type),r'(script|json|html|css|xml|plain)') as type,
IF (REGEXP_MATCH(LOWER(resp_content_encoding), r'gzip|deflate'), INTEGER(1), INTEGER(0)) AS compressed,
FROM [httparchive:runs.latest_requests]
)
WHERE type IS NOT NULL
GROUP BY type, compressed
)
) ORDER BY type, compressed DESC
Note: some responses (~4%) don’t provide a content-type while they claim to apply gzip/deflate to the response… these are excluded from above calculation.
- 47% of HTML resources are served without gzip or deflate
- 36% of CSS resources are served without gzip or deflate
- 26% of JS resources are served without gzip or deflate
In total, ~37% of resources are served as uncompressed.