Marc Aymerich
November 02, 2013 10:58AM
On Sat, Nov 2, 2013 at 1:10 PM, Maxim Dounin <mdounin@mdounin.ru> wrote:

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

Wowo that's it :)

# wget --no-check https://[fdf5:5351:1dfd:0:0:0:0:2]/api/ -S --header
'If-None-Match: "83393a3900e4abce27212d7a27cae589"' -q
HTTP/1.1 304 Not Modified
Server: nginx/1.4.1
Date: Sat, 02 Nov 2013 14:53:29 GMT
Connection: keep-alive
Vary: Accept, Cookie, Accept-Encoding
Last-Modified: Sat, 02 Nov 2013 14:53:29 GMT
ETag: "83393a3900e4abce27212d7a27cae589"
Allow: GET, HEAD, OPTIONS
Expires: Sat, 02 Nov 2013 14:54:29 GMT
Cache-Control: max-age=60

Thank you very much for your help maxim!

Shall I report this to nginx bug tracker?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Honoring ETag of cached content

Marc Aymerich November 01, 2013 05:30PM

Re: Honoring ETag of cached content

Maxim Dounin November 01, 2013 07:18PM

Re: Honoring ETag of cached content

Marc Aymerich November 01, 2013 09:56PM

Re: Honoring ETag of cached content

Maxim Dounin November 02, 2013 08:12AM

Re: Honoring ETag of cached content

Marc Aymerich November 02, 2013 10:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 209
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready