Facebook Pixel

What is Brotli and should I use it?

Brotli is a compression algorithm that's ~15-20% better than gzip for text content. Install libnginx-mod-http-brotli-filter, enable with brotli on and brotli_comp_level 6. Use it alongside or instead of gzip for better compression.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Nginx Performance Updates and Optimization Gzip, Caching, and Worker Tuning

Enable gzip compression (level 6, text types), cache static files for 1 year with immutable, use proxy_buffering to free Node.js, enable keep-alive connections (65s timeout, 32 upstream), use HTTP/2, set worker_processes auto with 2048 connections, and disable access logging for static files.

Add a location block matching static file extensions (js, css, png, jpg, etc.) with expires 1y, add_header Cache-Control 'public, immutable', and access_log off. React build files have hashed names so aggressive caching is safe new versions get new URLs.

proxy_buffering on makes Nginx collect the full response from Node.js before sending to the client. This frees Node.js to handle other requests instead of streaming slowly to the client. Set proxy_buffer_size 4k and proxy_buffers 8 4k for typical API responses.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0