• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Swift Guides

Howtos, Tutorials & Guides

  • Home
  • Servers
  • Applications
  • Opinions
  • Search
You are here: Home / Servers / How to Boost Nginx Performance?

How to Boost Nginx Performance?

June 3, 2024 by Sourabh Verma

Nginx is a fast, open-source, and reliable web server. More than 40% of websites use Nginx because it needs fewer resources, high scalability, easy configuration, and support for various protocols. Still, there are some tuning tips that you can use to boost Nginx performance.

Boost-Nginx-performance
Boost-Nginx-performance

Following the mentioned changes, your website’s performance will increase by 50%.

Prerequisites

  • Working server with LEMP installed and configured. You can follow our initial setup guide for Ubuntu or initial setup guide for Rocky or Alma Linux here.
  • Root or sudo user

Enabling HTTP2

When you open your virtual host file, you will find some directives as

listen [::]:443 ssl ipv6only=on;
listen 443 ssl;

Add “http2” as a suffix as shown below

listen [::]:443 ssl http2 ipv6only=on;
listen 443 ssl http2;

Press “Ctrl+x“, “y” and hit “Enter” to save the file

It’s done. You have successfully enabled “Http2” to your webserver.

SSL Caching and optimization

Almost every website today uses SSL. It’s the most basic thing that we add while configuring the web server. Whenever a user visits your website, an SSL handshake takes place between the browser and the server. Initial handshaking is the most taxing part, to avoid that we use SSL caching that will improve the overall performance of a website.

Open nginx.conf file

$ sudo nano /etc/nginx/nginx.conf

Copy and paste the below-mentioned code under http { block

# SSL
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;

Press “Ctrl+x” “y” and hit “Enter” to save the file

Enabling Gzip

The website’s performance depends a lot on the size of the files. The bigger the size of the file the longer it will take to download and open. With Gzip, we will compress all the files that will move to the user’s browser. Gzip is a module that comes installed by default with Nginx and we have to enable it by making some changes

Open nginx.conf file

$ sudo nano /etc/nginx/nginx.conf

Find the gzip directive and make changes as mentioned below

##
# `gzip` Settings
#
#
gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types
  application/atom+xml
  application/geo+json
  application/javascript
  application/x-javascript
  application/json
  application/ld+json
  application/manifest+json
  application/rdf+xml
  application/rss+xml
  application/xhtml+xml
  application/xml
  font/eot
  font/otf
  font/ttf
  image/svg+xml
  text/css
  text/javascript
  text/plain
  text/xml;

Press “Ctrl+x” “y” and hit “Enter” to save the file

It’s done. Gzip if enabled in your website.

Category: Servers Tagged In: Nginx, rocky, Server, Ubuntu

Like my work? Don't Forget to Share

Share on Facebook Share on Twitter Share on LinkedIn Share on Reddit Share on WhatsApp Share via Email

Hi, welcome to SwiftGuides! With over 12 years of experience in Linux, SysAdmin, databases, cloud computing, and other IT-related areas, I make sure publish easy-to-follow, 100% working tutorials. I hope you like my work. Thanks!

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Stay With Us

Follow on Facebook Follow on Twitter Follow on LinkedIn Follow on Reddit Subscribe on YouTube Follow on Instagram

SwiftGuides: Howtos, Tutorials & Guides © 2025 ยท All Rights Reserved

  • Contact Us
  • Privacy Policy
  • Disclaimer