2012-06-08 25 views
2

我正在使用以下設置運行我的producction環境,看來它正在縮小,但不是壓縮/壓縮響應。爲什麼我的js + css在Rails + Heroku的生產環境中沒有被壓縮?

# Disable Rails's static asset server (Apache or nginx will already do this) 
    config.serve_static_assets = false 

    # Compress JavaScripts and CSS 
    config.assets.compress = true 

    # Don't fallback to assets pipeline if a precompiled asset is missed 
    config.assets.compile = false 

    # Generate digests for assets URLs 
    config.assets.digest = true 

這是我的js文件,頭文件不包含gzip或deflate ???

$ curl -I http://sctest-perf.herokuapp.com/assets/application-1d21d488644b11e5610fa26bacdbc868.js 
HTTP/1.1 200 OK 
Age: 0 
Cache-Control: public, max-age=31536000 
Content-length: 213394 
Content-Type: application/javascript 
Date: Fri, 08 Jun 2012 20:34:58 GMT 
Etag: "1d21d488644b11e5610fa26bacdbc868" 
Last-Modified: Wed, 30 May 2012 16:38:32 GMT 
Status: 200 OK 
X-Content-Digest: 914bc6f80b0619be63c1302821ccc24a082ace53 
X-Rack-Cache: miss, store 
X-Request-Id: 76cb22ef23b73c440878569eec42ed4d 
X-Runtime: 0.001314 
X-Ua-Compatible: IE=Edge,chrome=1 
Connection: keep-alive 

回答

9

你需要編輯config.ru文件,位於項目根:

​​
3

您也可以嘗試使用這些寶石,這是爲了幫助優化資產服務的一個過程還。

https://github.com/romanbsd/heroku-deflater

https://github.com/mattolson/heroku_rails_deflate

如果我不使用use Rack::Deflater誤也壓縮圖像浪費了資源,是沒有用的。

+0

有趣的是,我不知道這件事。這些都是Heroku特定的解決方案。但是最好看一下他們的源代碼並複製它,而不是盲目地添加我提供的那一行。謝謝,我想我從現在開始使用'heroku-deflater'。 – Ashitaka

相關問題