DEV Community

Cover image for Accelerate your website with Nginx as a reverse proxy cache

Accelerate your website with Nginx as a reverse proxy cache

Shameem Reza on January 06, 2019

Optimizing Web Performance is a pending issue that we must continually work on. There are multiple solutions to improve our response times. ...
Collapse
 
nimatrazmjo profile image
Nimatullah Razmjo

Hi,
Thanks for the article. I have a question. If I cache all my assets(images, font, css).

How does the nginx cache work? If I hard refresh the page does it get the data from the folder or from cache?

Collapse
 
shameemreza profile image
Shameem Reza

You are welcome @nimatullah and thanks for reading my articles.

Nginx's cache is powerful! It can cache proxied HTTP requests, however it can also cache the results of FastCGI, uWSGI proxied requests and even the results of load balanced requests (requests sent "upstream"). This means we can cache the results of requests to our dynamic applications.

By the way, I will suggest you read this article: nginx.com/blog/nginx-caching-guide/ or do some research using google.

Collapse
 
lautarocastillo profile image
Lautaro C

Hi Shameen, very interesting article! I have a doubt about using Nginx with dynamic content. Could I store on cache some JSON responses from my Rails server? Many thanks

Collapse
 
shameemreza profile image
Shameem Reza

Yes you can. But probably you need to do some sockets configuration to cache JSON response on Rails server. You can read this guide for clear understanding: medium.com/@leshchuk/http-cache-on...

Collapse
 
david_j_eddy profile image
David J Eddy

Thanks for the article @Shammeem Reza. Loves me some nginx. So many features, so little time.

Collapse
 
shameemreza profile image
Shameem Reza

You are welcome @david_j_eddy and happy to know that you like it.

Collapse
 
alexjitbit profile image
Alex Yumashev

Thanks for the article! But is there any way to tell nginx-proxy which content to cache? URL-masks, regex, wildcards or something - WITHOUT touching the origin server?