Co to jest Compression?
Szybka definicja
Kompresja webowa zmniejsza rozmiar plików przesyłanych między serwerem a przeglądarką, dramatycznie redukując ilość pobieranych danych i przyspieszając ładowanie.
When a browser requests a web page, the server can compress the response before sending it. The browser then decompresses it — this entire process is transparent to users but can reduce transfer sizes by 60-90% for text-based files like HTML, CSS, JavaScript, JSON, and SVG.
Gzip has been the standard compression algorithm for the web since the late 1990s. It typically achieves 60-80% compression ratios on text files. Brotli, developed by Google and released in 2015, offers 15-25% better compression than gzip, especially for static content. Most modern browsers support both.
Compression is enabled at the server or CDN level. Most web servers (Nginx, Apache) and cloud platforms (Vercel, Cloudflare, AWS) enable compression by default. The browser signals which compression algorithms it supports via the Accept-Encoding header, and the server responds with the best available option.
Compression works best on text-based formats. Images, videos, and other binary files that are already compressed (JPEG, PNG, MP4, ZIP) don't benefit much from additional compression and may even get slightly larger. These should be optimized using format-specific techniques instead.
Dlaczego jest ważne
Compression is one of the easiest and most impactful performance optimizations. It requires zero code changes and can reduce page weight by 70% or more. There's essentially no downside — the CPU cost of compression/decompression is negligible compared to the bandwidth savings.
Enabling Brotli compression when available provides a meaningful improvement over gzip with no user-facing tradeoffs.
Przykłady z życia
A corporate website's 500KB JavaScript bundle compressed to 95KB with gzip and 80KB with Brotli, loading in 0.5 seconds instead of 3 seconds on mobile
An API response that was 2MB of JSON compressed to 180KB with Brotli, reducing API latency from 4 seconds to under 1 second on 4G connections
A hosting migration accidentally disabled gzip compression, doubling page load times overnight — re-enabling it immediately restored performance
A static site using Brotli pre-compression at build time (instead of on-the-fly) achieved maximum compression ratios while adding zero server CPU overhead
Powiązane pojęcia
Page Speed
Szybkość strony to miara szybkości ładowania i interaktywności strony internetowej, bezpośrednio wpływająca na doświadczenie użytkownika i pozycje w wyszukiwarkach.
Minification
Minifikacja to proces usuwania zbędnych znaków — spacji, komentarzy, nowych wierszy — z kodu źródłowego (CSS, JavaScript lub HTML) w celu zmniejszenia rozmiaru plików.
CDN (Content Delivery Network)
CDN to sieć geograficznie rozproszonych serwerów dostarczających treści webowe użytkownikom z serwera najbliższego ich lokalizacji, skracając czasy ładowania.
HTTP/2
HTTP/2 to druga główna wersja protokołu HTTP, poprawiająca wydajność dzięki multipleksowaniu, kompresji nagłówków i server push.
Potrzebujesz pomocy z compression?
Nasz zespół może pomóc Ci zastosować to pojęcie w praktyce. Uzyskaj bezpłatną konsultację, aby omówić swój projekt.