Lets say my backend takes a horrific 2 seconds to respond (out of our control say), and I never EVER want a visitor to experience this delay, we are not influenced by cookies or user session.
What I want to do in nginx is something like this:
server {
location / {
# server requests from cache unless for some reason its not in cache
proxy_pass http://backend/
proxy_cache mycache
proxy_cache_is_valid 2m
}
location / where request IP = 127.0.0.1 {
proxy_pass http://backend/
do_not_use_cache
but_store response in cache
}
}
This way I can have a simple curl task from localhost run every 30 seconds that keeps the cache fresh/hot with the several pages I need, I never want the visitor to be the one that warms up the cache. I've read the docs but cant see how to make this happen.