November 8th, 2020 at 5:04 pm

Take full control over the NGINX Cache with Cache Commander!

7 minutes reading


What is NGINX?

When NGINX first came into being, the primary purpose was for it to be the fastest, most stable, and reliable webserver to date. Not only was that the case at the time, but NGINX gained so much popularity due to its success and the fact that it is open-source that developers started looking for different ways they can utilize its simplicity and effectiveness. Eventually, NGINX started seeing use as a reverse proxy and a load balancer, thus outshining and outperforming the competition when serving static content and handing many concurrent requests. 

Nginx is the second most used web server in the world after Apache, and the gap between them keeps narrowing down with each year. Many high-traffic and famous websites such as Netflix, WordPress, and even NASA chose to use it due to its promising results.

How does NGINX improve performance?

NGINX Web Server Logo

NGINX is an event-based web server that excels in handling many concurrent requests while offering fast response times and employing low memory usage. NGINX uses an asynchronous approach to supervise multiple requests without spawning new threads or processes for each concurrent query.

This approach allows one master process to serve numerous concurrent requests without opening new connections and increase the server’s memory consumption. The workers execute requests while being supervised by the master process, leading to almost no impact on server performance and memory usage.

Another factor that improves the loading speed and performance of websites is the NGINX caching. When enabled, NGINX caches both static and dynamic content by saving responses in a disk cache and using them to respond to visitor requests. This avoids the need to proxy the requests for the same content every time thus, speeding up the process significantly.

A website consists of two types of data structures – static content and dynamic content. 

  • Static content – Static content is something that changes very rarely, such as the background color of your site, your site’s logo, or the name of your menus in the header.
  • Dynamic content – Dynamic content is a piece of online data that changes regularly (hence the name), and it varies based on many factors, such as the user’s location and preference. An excellent example of dynamic content is the “Recommended” areas of a video website or a blog, which will dynamically generate content for you based on what you previously looked at or searched. Such content is cached for a short time, leading to performance improvement and lower hardware resource consumption for compiling the content with every subsequent request.

When a person browsing the internet accesses your website, this request gets forwarded to the respective web server(s). In our case, this is both Apache & NGINX. NGINX will handle your web page request and create a snapshot caching both the static and dynamic content. Due to the nature of dynamic resources, the cache lasts for a few seconds to ensure that when there is a lot of traffic, NGINX can deliver the snapshotted versions directly from the cache and keep your server and website stable.

The static cache lasts for a more extended period, as it is changed very rarely, and each time a static resource is requested, NGINX pulls it from the static cache and delivers it to the browser. Apache comes into the equation when visitors request individual pieces of dynamic content, and it just compiles it and takes it to the visitor. This entire process speeds up the whole server’s content delivery, making your website noticeably faster in the process, and allows it to sustain much more traffic than usual.

How did we decide to use NGINX?

The NGINX web server has significant advantages over other popular web servers and tends to outperform them in several critical performance-related aspects. Naturally, we did a lot of research before we decided to integrate NGINX on our servers, and we believe that we found an excellent balance.

We decided to use NGINX as a Reverse Proxy to the Apache webserver to employ the best of both worlds – Apache’s high versatility due to its various modules and NGINX’s stability and performance-enhancing capabilities. This setup has proven to be the most optimal as it delivers exceptional performance, and we feel very confident in introducing it to our clients. 

 

We did many tests during the implementation process, and naturally, we also encountered a few issues. Our team did a lot of brainstorming, and we ended up with the perfect setup for our production servers. The performance boost NGINX brought was very noticeable, and we were delighted with the results. Our users also give us fantastic feedback on how their sites have lifted off since they started using HostArmada packages with NGINX, which confirmed that we were moving in the right direction.

We made a series of blog posts showing what NGINX can produce when combined with proper caching plugins on the most widely-used opensource application – WordPress. We highly recommend NGINX to WordPress website owners no matter the scale of their project. Of course, if you are hosting your websites with us, we will be happy to help you fine-tune your WordPress site by implementing the best possible caching plugin combination. Our support team is 24/7 available at your disposal, so please be sure to contact them if you need a hand!

Initial problems with NGINX and development ideas behind the Cache Commander

After first integrating NGINX, we had a few concerns in mind: cache management and cache exclusion. We enabled NGINX by default in its first iteration and let it work freely on the server and do its magic. However, we started noticing that some websites were being cached way too aggressively, resulting in clients reporting that some of the changes they performed on their websites were not visible. 

We had to do something about it, and thus, we envisioned a way of allowing clients to clear the NGINX cache on their sites or completely exclude them from dynamic or static caching. This implementation aims to enable clients to clear their cache when they make changes to their static resources. Additionally, they will be able to exclude any domain they wish. This option is useful when they want to build new sites and prevent any unwanted caching issues.

The “Cache Commander” is an in-house built cPanel feature that allows clients to manage NGINX for their domains from the convenience of their hosting account. It is the perfect solution for handling your static and dynamic caches and excludes domain names from the NGINX configuration. To learn how to access it and manage your domains on our NGINX hosting solutions, please be sure to check our tutorial on the matter.

Which plans did we choose for NGINX?

The hosting plans where we decided to set up NGINX are our Start Dock, Web Warp, VPS cloud, and Dedicated CPU cloud servers. The “Cache Commander” functionality is available on all of them, securing the ultimate control you need to manage your caching. If you need any assistance picking the best NGINX hosting plan for your needs, feel free to contact our sales team over the live chat. They will be more than happy to point you towards the best solution where your website will take the most advantage out of this genuinely fantastic web server.

Final Thoughts

NGINX is a staple in website performance for more than a decade, and it shows no signs of stopping. If you are among the unfortunate users suffering from a slow loading website, perhaps the time to consider changing your web hosting provider has come. We are sure you will enjoy the NGINX server’s full potential and the great benefits of the NGINX cache, which will significantly improve your website’s loading speed and overall performance. Thanks to our extended 45-Day Money-Back Policy, you are welcome to test our services completely risk-free and get a first-hand experience.