How to configure nginx for JBoss?

Is there a way to tell nginx which page to cache and how long to cache from an expressjs application running behind an nginx serving?

  • Here nginx is serving as reverse proxy, and i don't want to play with nginx configuration , i just want to configure it dynmically from expressjs. I want to think it is possible by sending some specific headers like "Cache-Control" header. Expressjs is an example here, it may be any other application.

  • Answer:

    You can add location directives in the config, putting specific configuration directives for specific URLs and URL patterns i.e. location /mystaticpage {   expires 1h;   add_header Cache-Control "max-age=3600"; } For the nginx itself to cache (using as http proxy) you can use in that location something like proxy_cache_valid 200 404 10m; that caches for 10 minutes what came with response code like 200 or 404 from that location.

Gustavo Muslera at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.