2012-03-15 49 views
2

我正在嘗試升級到雪松/資產管道,並且在忙於某些事情。如何獲取資產緩存工作

一切都呈現良好,但我的應用程序似乎明顯慢。展望thorugh我的日誌我看到噸的項目像這樣:

2012-03-15T17:03:02 + 00:00的應用[web.1]:緩存:GET /assets/application.js]小姐2012-03-15T17:03:02 + 00:00 app [web.1]: 緩存:[GET /assets/down_arrow.gif]小姐2012-03-15T17:03:02 + 00:00 app [ web.1]:緩存:[GET /assets/application.css]錯過

我希望這些是命中 - 對吧?

我production.rb

config.cache_classes = true 

    # Full error reports are disabled and caching is turned on 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 

    # For nginx: 
    config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' 

    # I also tried these 
    # config.action_dispatch.x_sendfile_header = "X-Sendfile" 
    # config.action_dispatch.x_sendfile_header = nil 

    config.cache_store = :dalli_store 

我的application.rb中

... 

    config.assets.enabled = true 

    # Version of your assets, change this if you want to expire all your assets 
    config.assets.version = '1.0' 

    config.assets.initialize_on_precompile = false 

    config.active_support.deprecation = :log 

注意:assets:precompile上部署工作正常:

-----> Preparing app for Rails asset pipeline 
     Running: rake assets:precompile 
-----> Rails plugin injection 
     Injecting rails_log_stdout 
     Injecting rails3_serve_static_assets 

謝謝!如果您需要更多信息,請告知我

+0

當您部署時,您是否在您的heroku日誌中看到資產編譯? – phoet 2012-03-16 17:00:07

+0

應該有類似'----->爲Rails資產管道準備應用程序 運行:rake資產:預編譯「 – phoet 2012-03-16 17:00:36

+0

yup - 我將用該信息更新該問題 – Jonathan 2012-03-16 17:26:23

回答

-2

我提出了與Heroku的支持票,並在這裏是有迴應:

我給這一個鏡頭: http://jackchu.com/blog/2011/09/20/rails-asset-pipeline-content-delivery-networks-and-rack-cache/

最近的調查Rack :: Cache和memcached/dalli似乎是在Rails 3.1+中破解的 。

這似乎是訣竅。我期待Rack :: Cache和dalli之間的交互得到解決,但同時我會遵循@jackchu方法

+0

此URL現在是404。這裏有任何更新? – 2014-04-23 22:41:10

+0

僅供參考,我在這裏找到它:http://jackchu.com/2011/09/20/rails-asset-pipeline-content-delivery-networks-and-rack-cache/ – ilasno 2014-11-11 17:12:58

-1

您可能錯過了許多資產管道配置之一。看看我的production.rb文件:

HamburgOnRuby::Application.configure do 
    # Settings specified here will take precedence over those in config/application.rb 

    # Code is not reloaded between requests 
    config.cache_classes = true 

    # Full error reports are disabled and caching is turned on 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 

    # 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 

    # Compress both stylesheets and JavaScripts 
    config.assets.js_compressor = :uglifier 
    config.assets.css_compressor = :scss 

    # Defaults to Rails.root.join("public/assets") 
    # config.assets.manifest = YOUR_PATH 

    # Specifies the header that your server uses for sending files 
    # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 
    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 
    config.action_dispatch.x_sendfile_header = nil # http://devcenter.heroku.com/articles/rails31_heroku_cedar#the_asset_pipeline 

    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 
    # config.force_ssl = true 

    # See everything in the log (default is :info) 
    # config.log_level = :debug 

    # Use a different logger for distributed setups 
    # config.logger = SyslogLogger.new 

    # Use a different cache store in production 
    # config.cache_store = :mem_cache_store 

    # Enable serving of images, stylesheets, and JavaScripts from an asset server 
    # config.action_controller.asset_host = "http://assets.example.com" 

    # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 
    config.assets.precompile += %w(active_admin.js active_admin.css) 

    # Disable delivery errors, bad email addresses will be ignored 
    config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.smtp_settings = { 
    :address  => "smtp.sendgrid.net", 
    :port   => "25", 
    :authentication => :plain, 
    :user_name  => ENV['SENDGRID_USERNAME'], 
    :password  => ENV['SENDGRID_PASSWORD'], 
    :domain   => ENV['SENDGRID_DOMAIN'] 
    } 

    # Enable threaded mode 
    # config.threadsafe! 

    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 
    # the I18n.default_locale when a translation can not be found) 
    config.i18n.fallbacks = true 

    # Send deprecation notices to registered listeners 
    config.active_support.deprecation = :notify 

    # Set the default host for production 
    config.default_host = 'onruby.de' 
end