expressjs / compression

Node.js compression middleware
MIT License
2.77k stars 241 forks source link

Duplicate json response back to the browser #66

Closed jadbox closed 9 years ago

jadbox commented 9 years ago

I'm getting this odd issue with compression I believe. When enabled, every call that responds with json gets "duplicated" back to the browser somehow. Checking in Chrome/Firefox, I see static assets gzip'ed without issue, but json responses are duplicated in the network log. Below is what I see for the first and second request the browser does when trying to "fetch" a single json server endpoint:

First Response Request Method:GET Status Code:200 OK

Response Headers Connection:keep-alive Content-Encoding:gzip Content-Length:146 Content-Type:application/json; charset=utf-8 Date:Thu, 19 Nov 2015 06:33:25 GMT ETag:W/"fa-L10DQ3THKdynxVS31hYiqA" Server:nginx/1.8.0 Vary:Accept-Encoding X-Powered-By:Express

Request Headers view source Accept:/ Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive DNT:1 Host:x.com If-None-Match:W/"fa-jZprvnhPXrhfIWf038GTKw" Referer:x User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36

Second Response Request Method:GET Status Code:304 Not Modified

Response Headers view source Connection:keep-alive Date:Thu, 19 Nov 2015 06:33:25 GMT ETag:W/"fa-jZprvnhPXrhfIWf038GTKw" Server:nginx/1.8.0 X-Powered-By:Express

Request Headers view source Accept:/ Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive DNT:1 If-None-Match:W/"fa-jZprvnhPXrhfIWf038GTKw" Referer:x User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36

Perhaps related to this? https://github.com/expressjs/compression/issues/20

dougwilson commented 9 years ago

Hi! The issue you are referring to ended up being the user was using a buggy version of livereload and they had to upgrade it to fix the issue.

If that does not solve it for you, can you please provide full instructions and code so I can reproduce this issue?

jadbox commented 9 years ago

I figured it out it was a bug on my behalf.