在Heroku,Dalli gem和Memcachier上使用Rails 3.1.1。緩存memcache中的caches_action fragmens和文件系統中的資產
我想解決一個問題where keys disappear from Memcachier,爲了做到這一點,我想確保只有我的caches_action中的內容纔會被緩存在memcache中。我希望我的資產(jpg等)可以緩存在其他地方。
我相信這是相同的問題this question但是當我做相同的,即加入
config.action_dispatch.rack_cache = {
:metastore => Dalli::Client.new,
:entitystore => 'file:tmp/cache/rack/body',
:allow_reload => false
}
我production.rb,它並沒有真正似乎無所不能。
我production.rb全:
MyDemoApp::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 = true
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
# 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
# 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
# Prepend all log lines with the following tags
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
config.cache_store = :dalli_store
config.action_dispatch.rack_cache = {
:metastore => Dalli::Client.new,
:entitystore => 'file:tmp/cache/rack/body',
:allow_reload => false
}
# Set expire header of 30 days for static files
config.static_cache_control = "public, max-age=2592000"
# 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(search.js)
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# 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
end
緩存資產做工精細(獲得緩存新鮮的反應)和緩存的操作是這樣的:
caches_action :show, :layout => false, :expires_in => 3.days
還會在一個緩存項Rails緩存(雖然他們在一段時間後消失)。
我現在的問題是:如果可能,我該如何才能讓我的caches_action片段最終在我的Memcache中(而不是我的資產)?
一個額外的問題是,你是否在我的production.rb中看到任何不尋常的東西?
請不要在帖子中使用簽名/標語。您的用戶箱計爲您的簽名,您可以使用您的個人資料發佈您喜歡的任何關於您自己的信息。 [關於簽名/標語的常見問題](http://stackoverflow.com/faq#signatures) –