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
Related Q & A:
- How can I tell how long I've been a member of Yahoo?Best solution by answers.yahoo.com
- How long is too long for a sprained ankle to heal?Best solution by Yahoo! Answers
- Is there a way to tell if I have alcohol fetal syndrome?Best solution by Yahoo! Answers
- How long should I give a prof to write a letter of recommendation for a graduate school application?Best solution by Yahoo! Answers
- Is there a way to see who's been looking at my Facebook page?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.