Ruby on rails 缓存在Memcache中缓存\u操作框架,并在文件系统中缓存资产
在Heroku、Dalli gem和Memcachier上使用Rails 3.1.1 我正在尝试解决一个问题,为了解决这个问题,我希望确保只有来自我的caches\u操作的内容才会缓存在memcache中。我希望我的资产(jpg等)被缓存到其他地方 我相信这是同一个问题,但当我做同样的事情,即添加Ruby on rails 缓存在Memcache中缓存\u操作框架,并在文件系统中缓存资产,ruby-on-rails,caching,Ruby On Rails,Caching,在Heroku、Dalli gem和Memcachier上使用Rails 3.1.1 我正在尝试解决一个问题,为了解决这个问题,我希望确保只有来自我的caches\u操作的内容才会缓存在memcache中。我希望我的资产(jpg等)被缓存到其他地方 我相信这是同一个问题,但当我做同样的事情,即添加 config.action_dispatch.rack_cache = { :metastore => Dalli::Client.new, :entitystore =>
config.action_dispatch.rack_cache = {
:metastore => Dalli::Client.new,
:entitystore => 'file:tmp/cache/rack/body',
:allow_reload => false
}
对我的production.rb来说,它似乎没有什么作用
Myproduction.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缓存中创建一个缓存项(尽管它们会在一段时间后消失)
我现在的问题是:如果可能的话,我如何做到只有我的缓存\u动作片段最终进入我的Memcache(而不是我的资产)
一个额外的问题是,你在我的制作中看到了什么与众不同的东西吗?rb?我使用gem“asset\u sync”将我的所有资产转移到Amamzon S3 参见说明 你有三个优势:
- 您的资产由Amazon提供,因此页面加载速度更快 使用者
- 你在Heroku上的弹头尺寸更小,应该更大 性能
- 您的资产将不再在memecahce中
在Amamzon上主持我的所有资产每三个月就要花费我大约20美分请不要在帖子中使用签名/标语。您的用户框算作您的签名,您可以使用您的个人资料发布您喜欢的任何关于您自己的信息。