solidusjs / solidus

A simple server that generates pages from JSON and Templates
MIT License
28 stars 7 forks source link

Retrieve compressed resources if possible. #81

Closed joanniclaborde closed 10 years ago

joanniclaborde commented 10 years ago

Branch: f6Cl9nWE-enable-resource-compression

https://trello.com/c/f6Cl9nWE/651-enable-hipster-response-compression

Fauntleroy commented 10 years ago

Where can I find some compressed resources to test against?

joanniclaborde commented 10 years ago

EdgeCast will gzip a cached resource if you ask for it. Make sure to test more than once; the first request is not compressed (EdgeCast zips in background), but later requests are zipped.

Fauntleroy commented 10 years ago

I'm not seeing compressed resources come back from staging: headers

{ 'cache-control': 'max-age=153',
  'content-type': 'application/json',
  date: 'Tue, 11 Feb 2014 02:24:29 GMT',
  expires: 'Tue, 11 Feb 2014 02:27:03 UTC',
  server: 'Goliath',
  vary: 'Project,Api-Key,Accept',
  'content-length': '626',
  connection: 'close' }

other headers

{ server: 'nginx',
  date: 'Tue, 11 Feb 2014 02:24:29 GMT',
  'content-type': 'text/html;charset=utf-8',
  'content-length': '23',
  connection: 'close',
  'x-frame-options': 'sameorigin',
  'x-xss-protection': '1; mode=block' }
joanniclaborde commented 10 years ago

If you're seeing server: 'Goliath' this means you're not being served by EdgeCast, but by Hipster...

Also, how come you get server: 'nginx'? Maybe not a resource on storyteller.io?

Fauntleroy commented 10 years ago

One resource isn't on storyteller, so that's probably where the nginx response came from. Just so we're clear, this resource should eventually return a cached version from edgecast, right? http://staging.proxy.storyteller.io/soundcloud/users/fauntlero-von-patton/favorites.json

joanniclaborde commented 10 years ago

Yes, and gzipped if you asked for it in the request headers.

joanniclaborde commented 10 years ago

But it should be pretty quick, within like 10 seconds if you make repeated requests with the same url and headers.

Fauntleroy commented 10 years ago

@joanniclaborde if these changes make sense to you, let's go ahead and merge this.

Fauntleroy commented 10 years ago

I think ultimately we want to do something like response_stream = res.pipe( new zlib.Unzip() ).pipe( JSONStream.parse() ) but I'd like to get more familiar with decoding JSON while inside a stream first.

joanniclaborde commented 10 years ago

Changes look good, tests pass, local test works too, I'll merge this into master.