DEV Community

Cover image for ๐Ÿš€ From 2โ€“5 Minutes to < 1 Second: How a Small Nginx Config Change Boosted My Website
Ferry Ananda Febian
Ferry Ananda Febian

Posted on

๐Ÿš€ From 2โ€“5 Minutes to < 1 Second: How a Small Nginx Config Change Boosted My Website

A few days ago, I was puzzled about why the website I built felt extremely slow when loading a JavaScript file.

Imagine this: a file of just 2 MB took 2โ€“5 minutes to load in the browser. ๐Ÿ˜…

After digging into it, the issue turned out to be simple: I forgot to enable gzip in my Nginx configuration.

What is gzip?

gzip is a compression method that allows the server to send smaller-sized files to the browser.

Instead of downloading the full raw file, the browser only needs to fetch the compressed version.

The Fix

I added the following config to my Nginx Proxy Manager:

gzip on; gzip_comp_level 6; gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript application/xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; 
Enter fullscreen mode Exit fullscreen mode

The Result

The website performance improved instantly:
From 2โ€“5 minutes โ†’ to less than 1 second for a 2 MB file.

Key Takeaways

  • Small optimizations can lead to massive improvements.
  • Never underestimate basic server configuration.
  • A single setting can completely transform user experience.

Sometimes itโ€™s not expensive hardware or the latest framework that makes a website faster, but rather a simple config tweak like this.

So, if your website feels slow, it might be worth checking whether gzip is enabled on your server.

Have you ever found a performance bottleneck where the solution turned out to be this simple?

Top comments (6)

Collapse
 
eloriva_fashion_7bbda577c profile image
Eloriva Fashion

I had the same issue before, and itโ€™s amazing how such a small config tweak can make a huge difference! I tried enabling gzip on my server as well, and the performance boost was instant. A 2 MB file loading in under a second was a game changer. It's crazy how basic server configurations can have such a massive impact on the user experience. Definitely a reminder not to overlook the simple optimizations!

Collapse
 
ferryops profile image
Ferry Ananda Febian

Thatโ€™s awesome, glad gzip made such a big difference for you! If you want even smaller transfers, consider trying Brotli.

Collapse
 
chanhlt profile image
Chanh Le

This is one of basic principles in web development: minimize the data (size) transport over the network.

Collapse
 
ferryops profile image
Ferry Ananda Febian

That's right, I'm curious to try encoding methods other than gzip.

Collapse
 
ferryops profile image
Ferry Ananda Febian

reserved

Some comments may only be visible to logged-in visitors. Sign in to view all comments.