s-maxage not being honored with proxy_cache

Ryan Parrish ryan.parrish at corelogicllc.com
Tue Apr 23 15:05:58 UTC 2013

I have a slow backend application that I'm using nginx to provide
the authentication and caching for.  It's been working great however there
is one nagging issue that I cannot seem to resolve, when the backend app
sets a s-maxage and a maxage Cache-Control, nginx only seems to honor the
maxage and expires the cache with its value.

An example response from the backend is like this...

Cache-Control: max-age=60, s-maxage=3600, public, must-revalidate
My idea here is I only want the client to cache this data for a short
amount of time before checking in with me it see if it's still valid.  The
data usually wont be changing that often so I want nginx to cache it for an
hour, but in the event it does I use the excellent nginx-cache-purge script
in my backend app to invalidate the cache and the next time a client checks
in (after 60 seconds) they will get the new data.

However in all my testing and usage I will only get a cache HIT for 60
seconds after the first request to a resource, after 60 seconds it will be
EXPIRED then it will go to the backend again.  Am I missing something in
the Cache-Control that is causing this behavior?


Ryan Parrish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130423/858c44b4/attachment.html>

More information about the nginx mailing list