Comments on Why You Should Always Use Nginx With Microcaching

Why You Should Always Use Nginx With Microcaching Everybody knows how hard is to push out as much as possible from your webserver(s). In my daily occupation as a hosting engineer that means I fairly often get the same question, "Wow, cool website, but can it cope with big-time traffic?".

9 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Julian Fernandes

What if i use Varnish? Should i still use Nginx with microcaching, or Varnish itself will be better?

Right now i have a WordPress blog with W3 Total Cache set for Disk (enhanced) page cache, Varnish, Nginx, PHP-FPM and CloudFlare Pro on top of all that. Speed is awesome, but i wonder if i could use microcaching in this setup? Was gonna try it last night, but there was too many visitors online.
 

 

 

By: frank

If you already have other caching systems I don't think you need microcaching, from what I understand microcaching caches items that generally are so dynamic that usually are not cached, but caching them for only seconds can reduce the load if the requests towards those cached objects is at least at the order of hundreds per second...

 Or maybe I am completely wrong :D

By: Gabriel

Hi, To answer your question simply, yes you can use Nginx microcaching with varnish, I did a test on a machine that has Varnish on port 80 and Nginx on port 8080

The microcaching comes on nginx layer which is cool and helps the server big time on nginx level.

I believe in caching so 2 3 layers of cache? If they don't conflict each other why not! :) 

 

By: Anonymous

Thanks for the article.

However, a lot of sites now are 2.0, meaning that the data included in the pages change all the time, so that the building block isn't in the web server or even the web application, but rather in the database in the back. Keeping multiple DB servers with write accesses in sync is a much harder task.

By: grails

Microcaching is so cool.  It gives you the impression that the site is still dynamic, but greatly improves performance!

By: Gwyneth Llewelyn

Thanks for the tutorial :)

I've tried this out on one of my WordPress installations, and used <a href="https://rtcamp.com/tutorials/nginx/upstream-cache-status-in-response-header/">this tip</a> to make sure that I could test out if the cache was really working or not.

That way, I can test with <b>curl -I http://my.website.tld</b> and see if I get a cache hit, miss, or bypass.

This works flawlessly for the homepage. I can then shutdown php5-fpm and Nginx will continue to respond to requests for the homepage — which is pretty cool indeed :D And the Nginx cache definitely starts to get a few entries :-)

Now, the problem is: this will work only for the homepage, everything else will be bypassed.

On rtCamp's site they suggest to turn off permalinks, then turn them back on, enable the Nginx helper plugin, turn it off, and so forth... whatever sequence I use, the result is always the same: everything works for the homepage. Nothing works for the rest of the content (it always gets bypassed).

I wonder if anyone has a clue why this is the case.

By: Gwyneth Llewelyn

It's stupid to reply to myself after a year, but I figured out what I had wrong. I'm also using WordPress, and some of my WordPress-specific configurations was forcing all URL rewrites to always include a query string. Since I was excluding anything with a query string from being cached, only the homepage worked... :)

By: Liew CheonFong

I see that you set the microcache to 10s in code, not 1s as you stated in article.

By: Enrique

Does this cahce acts for 1 second always? or we can increase the cache time (like hours for example) and also clean the cache at any moment somehow?