Text file should be compressed

ブログ作りの話も。

PaaSって、gzipを勝手にかけてくれる気がしていたんだけど、どうやら思い込みだったようで、 2012年ぐらいから、herokuはnginxを経由せずに、直接webrickにリクエストが送られるように仕様変更されたらしい。

参考:Enable gzip compression for Rails 3.2 on heroku Cedar

All apps deployed to Heroku used to automatically compress pages they serve, by passing through Nginx’s gzip filter on the way out. But with their newest Cedar Stack, things have changed.

In Cedar, the HTTP requests terminates directly at your app server & no longer goes through a proxy server(Nginx), hence there can’t be automatic gzip compression.

herokuのドキュメントはHTTP Routing and the Routing Mesh#Gzipped responsesに書いてある。

Since requests to Cedar apps are made directly to the application server – not proxied through an HTTP server like nginx – any compression of responses must be done within your application.

なので、この記事に従って最初に試してみたのはこんなコード。