<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 2, 2013 at 1:10 PM, 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello!<br>
<div><div class="h5"><br>
On Sat, Nov 02, 2013 at 02:55:09AM +0100, Marc Aymerich wrote:<br>
<br>
> On Sat, Nov 2, 2013 at 12:16 AM, Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br>
><br>
> > Hello!<br>
> ><br>
> > On Fri, Nov 01, 2013 at 10:29:06PM +0100, Marc Aymerich wrote:<br>
> ><br>
> > > Hi,<br>
> > > I'm using nginx proxy pass to cache content of our dynamic web<br>
> > application.<br>
> > ><br>
> > > In order to save some bandwidth our client application uses conditional<br>
> > > requests based on ETag. However nginx ignores the ETag of cached pages :(<br>
> > ><br>
> > > What would be required if I want to honor the ETag of cached pages? Is<br>
> > > something that can be achieve by means of configuration? or I would need<br>
> > to<br>
> > > write an nginx module in C?<br>
> ><br>
> > It is expected to just work in 1.3.3+. If you don't see it<br>
> > working, you may want to check the version you are running.<br>
><br>
><br>
> Hi maxim,<br>
> yeap I'm running 1.4.1 but I never get a 304 :(<br>
> This is what a response from cache looks like<br>
><br>
> # wget --no-check https://[fdf5:5351:1dfd:0:0:0:0:2]/api/ -S --header<br>
> 'If-None-Match: "83393a3900e4abce27212d7a27cae589"' -q<br>
> HTTP/1.1 200 OK<br>
> Server: nginx/1.4.1<br>
> Date: Sat, 02 Nov 2013 01:40:24 GMT<br>
> Content-Type: application/json<br>
> Transfer-Encoding: chunked<br>
> Connection: keep-alive<br>
> ETag: "83393a3900e4abce27212d7a27cae589"<br>
> Allow: GET, HEAD, OPTIONS<br>
> Vary: Accept, Cookie, Accept-Encoding<br>
> Expires: Sat, 02 Nov 2013 01:41:24 GMT<br>
> Cache-Control: max-age=60<br>
<br>
</div></div>[...]<br>
<div class="im"><br>
> Notice the etag value from cached content is different from the fresh one,<br>
> even though the content is exactly the same, I presume this is nginx doing<br>
> its job of updating the ETag for some differences because of caching, but<br>
> still fails to reply a conditional request properly :(<br>
<br>
</div>Ok, I see what goes on here. Condintional requests (even ones<br>
using ETag in If-None-Match) are only handled by nginx if there is<br>
Last-Modified response date set, and it's not set in your backend<br>
responses.<br>
<br>
This needs to be addressed, If-None-Match / If-Match handling from<br>
cache shouldn't require Last-Modified being present in a cached<br>
response. Meanwhile, you may add some Last-Modified to your<br>
backend responses as a workaround.<br>
<div class=""><div class="h5"></div></div></blockquote></div><br></div><div class="gmail_extra"><font color="#500050">Wowo that's it :)</font></div><div class="gmail_extra"><font color="#500050"><br></font></div><div class="gmail_extra">
<font color="#500050"><div class="gmail_extra"># wget --no-check https://[fdf5:5351:1dfd:0:0:0:0:2]/api/ -S --header 'If-None-Match: "83393a3900e4abce27212d7a27cae589"' -q</div><div class="gmail_extra">
HTTP/1.1 304 Not Modified</div>
<div class="gmail_extra"> Server: nginx/1.4.1</div><div class="gmail_extra"> Date: Sat, 02 Nov 2013 14:53:29 GMT</div><div class="gmail_extra"> Connection: keep-alive</div><div class="gmail_extra"> Vary: Accept, Cookie, Accept-Encoding</div>
<div class="gmail_extra"> Last-Modified: Sat, 02 Nov 2013 14:53:29 GMT</div><div class="gmail_extra"> ETag: "83393a3900e4abce27212d7a27cae589"</div><div class="gmail_extra"> Allow: GET, HEAD, OPTIONS<br></div>
<div class="gmail_extra"> Expires: Sat, 02 Nov 2013 14:54:29 GMT</div><div class="gmail_extra"> Cache-Control: max-age=60</div><div><br></div><div>Thank you very much for your help maxim! </div><div><br></div><div>Shall I report this to nginx bug tracker?</div>
<div><br></div></font></div></div>