<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 24, 2013 at 7:41 AM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<div class="im"><br>
On Tue, Apr 23, 2013 at 11:05:58AM -0400, Ryan Parrish wrote:<br>
<br>
> I have a slow backend application that I'm using nginx to provide<br>
> the authentication and caching for. It's been working great however there<br>
> is one nagging issue that I cannot seem to resolve, when the backend app<br>
> sets a s-maxage and a maxage Cache-Control, nginx only seems to honor the<br>
> maxage and expires the cache with its value.<br>
><br>
> An example response from the backend is like this...<br>
><br>
> Cache-Control: max-age=60, s-maxage=3600, public, must-revalidate<br>
> My idea here is I only want the client to cache this data for a short<br>
> amount of time before checking in with me it see if it's still valid. The<br>
> data usually wont be changing that often so I want nginx to cache it for an<br>
> hour, but in the event it does I use the excellent nginx-cache-purge script<br>
> in my backend app to invalidate the cache and the next time a client checks<br>
> in (after 60 seconds) they will get the new data.<br>
<br>
</div>Note: you will not be able to purge shared chaches outside of your<br>
control, so this might not work as you expect.<br>
<div class="im"><br>
> However in all my testing and usage I will only get a cache HIT for 60<br>
> seconds after the first request to a resource, after 60 seconds it will be<br>
> EXPIRED then it will go to the backend again. Am I missing something in<br>
> the Cache-Control that is causing this behavior?<br>
<br>
</div>As of now nginx doesn't handle s-maxage.<br>
<br>
Trivial solution is to use X-Accel-Expires to specifi expiration<br>
time for your nginx cache. This should also better match a use<br>
case you've described (as it will only ask your nginx cache to<br>
cache longer, not all shared caches in the world).<br><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div style>That worked perfectly, thank you!</div><div><br></div><div> </div>
</div><div><br></div>-- <br><div><br></div><div>--</div><div><br></div>Ryan Parrish<br>Chief Technologist, Member<br>CoreLogic LLC<br>M: (408)966-4673<br><a href="http://www.corelogicllc.com" target="_blank">www.corelogicllc.com</a><br>
<br>solutions for the extended enterprise
</div></div>