Nginx logo

Setting up Nginx, a leading web server, to cache content instead of using a dedicated application like Varnish is increasingly being adopted by many webmeisters.

But most of the online tutorials that show how to configure Nginx to cache content were copied from other sources that were also copies from other sources. And in virtually all the examples I’ve seen, there’s very little or no explanation of what each directive and parameter means and does.

That’s a recipe for setting up a system that does not cache or caches everything, even those that should not be cached. I think I’m guilty of the former, because this website does not appear to be caching, even though caching is configured.

So it’s refreshing to come across a blog post that explains all the basics clearly, including a few parameters that were introduced in more recent editions of Nginx. That the blog post is from the proverbial horse’s mouth makes it that much more authentic.

Related Post:  GRUB Customizer 4 released. Install it on Ubuntu 13.10 and Linux Mint 16

Nginx caching

So here’s an excerpt from the tutorial:

Last year I took on the task of performance tuning a website that was loading slowly. One of the first things I noticed was that it took over 1 second to generate the main home page. After some debugging, I discovered that because the page was marked as not cacheable, it was being dynamically generated in response to each request. The page itself was not changing very often and was not personalized, so this was not necessary. As an experiment, I marked the home page to be cached for 5 seconds, and just doing that resulted in noticeable improvement. The time to first byte went down to a few milliseconds and the page loaded visibly faster.

It’s not only large-scale content delivery networks (CDNs) that can benefit from caching – caching can boost the performance of the load balancers, reverse proxies, and web servers sitting in front of your application servers. As the above example shows, caching content results in more efficient usage of application servers because they don’t have to do the work of generating pages from scratch each time.

A web cache can be used to improve reliability as well. Rather than return an error to the user if the origin servers are down or busy, NGINX can be configured to deliver the stale content it already has in its cache. This means sites can remain partially or even fully functional in the case of a failure of the application servers or database.

You may read the complete article at A Guide to Caching with NGINX.

Related Post:  Autologin, passwordless login and controlling who can reboot and shutdown your computer in KDE

Share:

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn

Hola! Did you notice that LinuxBSDos.com no longer runs network ads?  Yep, no more ads from the usual suspects that track you across the Internet.  But since  I still need to pay to keep the site running, feel free to make a small donation by PayPal.

Subscribe for updates. Trust me, no spam!

Mailchimp Signup Form

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event for 2020.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.

Leave a Reply

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

Get the latest

On social media
Via my newsletter
Mailchimp Signup Form

Partner links

1. Attend Algorithm Conference, a top AI and ML event for 2021.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.
Hacking, pentesting distributions

Linux Distributions for Hacking

Experts use these Linux distributions for hacking, digital forensics, and pentesting.

Categories
Archives

The authors of these books are confirmed to speak during

Algorithm Conference

T-minus AI

Author was the first chairperson of AI for the U.S. Air Force.

The case for killer robots

Author is the Director of the Center for Natural and Artificial Intelligence.

Why greatness cannot be planned

Author works on AI safety as a Senior Research Scientist at Uber AI Labs.

Anastasia Marchenkova

An invitation from Anastasia Marchenkova

Hya, after stints as a quantum researcher at Georgia Tech Quantum Optics & Quantum Telecom Lab, and the University of Maryland Joint Quantum Institute, I’m now working on superconducting qubit quantum processors at Bleximo. I’ll be speaking during Algorithm Conference in Austin, Texas, July 16 – 18, 2020. Meet me there and let’s chat about progress and hype in quantum computing.