wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.22k stars 295 forks source link

If gzip is on Etag are stripped #194

Closed h0x91b closed 8 years ago

h0x91b commented 9 years ago

Not compressed request returns ETag as expected

curl -H "Accept: text/json" -H "Content-Type: text/json" -H "If-Modified-Since: Thu, 23 Jul 2015 13:36:04 GMT" -H "If-None-Match: 0" -v "http://mydomain.com/sub?id=29_status"
< HTTP/1.1 200 OK
* Server nginx/1.8.0 is not blacklisted
< Server: nginx/1.8.0
< Date: Thu, 23 Jul 2015 13:59:13 GMT
< Content-Type: text/plain
< Last-Modified: Thu, 23 Jul 2015 13:36:04 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Keep-Alive: timeout=20
< Expires: Thu, 01 Jan 1970 00:00:01 GMT
< Cache-Control: no-cache, no-store, must-revalidate
< Etag: 1
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: If-None-Match, If-Modified-Since, Origin, X-Date, Content-Type
< Access-Control-Expose-Headers: ETag

In case the gzip allowed headers without ETag...

curl -H "Accept: text/json" -H "Content-Type: text/json" -H "If-Modified-Since: Thu, 23 Jul 2015 13:36:04 GMT" -H "If-None-Match: 0" -v "http://mydomain.com/sub?id=29_status" --compressed

< HTTP/1.1 200 OK
* Server nginx/1.8.0 is not blacklisted
< Server: nginx/1.8.0
< Date: Thu, 23 Jul 2015 13:59:51 GMT
< Content-Type: text/plain
< Last-Modified: Thu, 23 Jul 2015 13:36:04 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Keep-Alive: timeout=20
< Expires: Thu, 01 Jan 1970 00:00:01 GMT
< Cache-Control: no-cache, no-store, must-revalidate
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: If-None-Match, If-Modified-Since, Origin, X-Date, Content-Type
< Access-Control-Expose-Headers: ETag
< Content-Encoding: gzip
wandenberg commented 9 years ago

Hi @h0x91b

I checked and since nginx 1.3.3 the Etag is cleared on gzip responses, and recent versions try to prefix the value with a "W/" when it is a string. You can try to work with the etag as a parameter, receiving the value on the message template. Check the curl examples on how not to use headers.

h0x91b commented 9 years ago

Long-Poll flow does not work correctly if Etag is not exists... Currently I`d find a workaround, just turned off gzip in /sub location, but it is not suitable for our solution.

wandenberg commented 9 years ago

It works without the Etag but you have to adjust your client and server. Did you take a look on this doc?

h0x91b commented 8 years ago

Nice :)) thanks for the doc I will use it

wandenberg commented 8 years ago

@h0x91b this commit 3da6cb0e03cbda6c3b8c850052c13a43754e48c5 allow to use the Etag header with the gzip filter on.