Перейти до основного вмісту
← 📄 HTML & the platform·Модуль A7 · Урок 11
ЗавданняBuild a minimal HTML page that the server can compress: doctype, html, head with charset + title 'Compressed', body with three paragraphs of placeholder text.

Стиснення: gzip, brotli, те, що має надсилати ваш сервер

75 XP6 min
Теорія

You're not setting this in HTML — but you need to know it exists

Compression happens at the HTTP layer. The server compresses, the browser decompresses, you never see it in your code. But it's THE most important "free" performance win:

  • gzip — 1992-era, widely supported. ~70% smaller than uncompressed text.
  • brotli (br) — 2013, faster + smaller than gzip. ~80% smaller than uncompressed. All modern browsers support it.

Your stack should serve Content-Encoding: br for any text response > 1KB.

How to verify

Open DevTools → Network → look at any .html / .css / .js request → "Response Headers" tab. Look for content-encoding: br (or gzip).

If you see no content-encoding header on a text response, your server isn't compressing. That's a 4x bandwidth waste.

Defaults by host

  • Vercel — brotli on, automatic.
  • Cloudflare — brotli on, automatic.
  • Netlify — brotli on, automatic.
  • Custom Nginx — you need to install ngx_brotli module + configure (gzip is built-in).
  • Apache — mod_deflate for gzip; brotli requires mod_brotli.

What NOT to compress

  • Images (.jpg, .png, .webp) — already compressed at the file level.
  • Fonts (.woff2) — already compressed.
  • Video — already compressed.

Compressing the un-compressible WASTES CPU. Configure your server to skip these MIME types.

🔒

Зареєструйся щоб кодувати

Теорія відкрита всім. Інтерактивний редактор, живий перегляд і перевірка відкриваються з 7-денним безкоштовним trial — потрібна картка, скасування у будь-який час.

Реєстрація — безкоштовний trial →

Перші 10 уроків у кожному треку — безкоштовні. Картка не потрібна.

← НазадНаступний урок →

Отримуй одну пораду з Python чи вебу — щодня поштою

Коротко, без води, без спаму. Відписка — в один клік.