我尝试将Actionpack 页面缓存与我的静态页面一起使用。如果我理解“Actionpack 页面缓存”工作是第一个到达轨道的请求。渲染视图,并将 Html 存储在缓存中 public/deploy/...
第二个类似的请求没有到达轨道。视图将不会呈现。将从缓存中取出一个页面。
但是在日志中它看起来完全不同。
《第一次请求》
I, [2013-08-16T12:24:43.591000 #16835] INFO -- : Rendered init/scene.html.erb within layouts/application (4.0ms)
I, [2013-08-16T12:24:43.615000 #16835] INFO -- : Rendered layouts/_server_params.html.erb (4.0ms)
I, [2013-08-16T12:24:43.624000 #16835] INFO -- : Rendered windows/_login_without_social_window.html.erb (2.0ms)
I, [2013-08-16T12:24:43.661000 #16835] INFO -- : Rendered windows/_choice_base_career_window.html.erb (34.0ms)
I, [2013-08-16T12:24:43.687000 #16835] INFO -- : Rendered windows/_auth_window.html.erb (21.0ms)
I, [2013-08-16T12:24:43.691000 #16835] INFO -- : Rendered windows/_free_teams_window.erb (2.0ms)
I, [2013-08-16T12:24:43.692000 #16835] INFO -- : Rendered layouts/_windows.html.erb (74.0ms)
I, [2013-08-16T12:24:43.775000 #16835] INFO -- : Rendered layouts/_bottom_menu.html.erb (80.0ms)
I, [2013-08-16T12:24:43.780000 #16835] INFO -- : Write page /home/pri/test/public/deploy/init/load_app.html (1.0ms)
I, [2013-08-16T12:24:43.782000 #16835] INFO -- : Completed 200 OK in 208ms (Views: 200.0ms | ActiveRecord: 0.0ms)
I, [2013-08-16T12:24:49.070000 #16835] INFO -- : Started GET "/init/load_app" for 127.0.0.1 at 2013-08-16 12:24:49 +0400
I, [2013-08-16T12:24:49.088000 #16835] INFO -- : Processing by InitController#load_app as HTML
“第二个请求”
I, [2013-08-16T12:24:49.096000 #16835] INFO -- : Rendered init/scene.html.erb within layouts/application (1.0ms)
I, [2013-08-16T12:24:49.108000 #16835] INFO -- : Rendered layouts/_server_params.html.erb (2.0ms)
I, [2013-08-16T12:24:49.112000 #16835] INFO -- : Rendered windows/_login_without_social_window.html.erb (1.0ms)
I, [2013-08-16T12:24:49.124000 #16835] INFO -- : Rendered windows/_choice_base_career_window.html.erb (10.0ms)
I, [2013-08-16T12:24:49.138000 #16835] INFO -- : Rendered windows/_auth_window.html.erb (11.0ms)
I, [2013-08-16T12:24:49.140000 #16835] INFO -- : Rendered windows/_free_teams_window.erb (1.0ms)
I, [2013-08-16T12:24:49.142000 #16835] INFO -- : Rendered layouts/_windows.html.erb (31.0ms)
I, [2013-08-16T12:24:49.161000 #16835] INFO -- : Rendered layouts/_bottom_menu.html.erb (16.0ms)
I, [2013-08-16T12:24:49.165000 #16835] INFO -- : Write page /home/pri/test/public/deploy/init/load_app.html (3.0ms)
I, [2013-08-16T12:24:49.167000 #16835] INFO -- : Completed 200 OK in 76ms (Views: 70.0ms | ActiveRecord: 0.0ms)
在所有请求中,视图都将呈现并缓存页面被覆盖。
我使用:rails 4.0.0
朱比
彪马服务器
生产方式
启动服务器 - RAILS_ENV=production rails s puma
我的生产.rb
ResFm::Application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.cache_store = :dalli_store
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
config.assets.compile = false
config.assets.digest = true
config.assets.version = '1.0'
config.assets.debug = false
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
# cache static pages
config.action_controller.page_cache_directory = "#{Rails.root.to_s}/public/deploy"
config.serve_static_assets = true
#CDN google servers
config.asset_host = 'http://resassets.appspot.com'
end
在控制器中我使用
caches_page :load_app
def load_app
end
这是一个根网址。
我的宝石文件
gem 'rails', '4.0.0'
gem 'activerecord-jdbcpostgresql-adapter', '~>1.3.0.beta2'
gem 'dalli'
gem 'jquery-ui-rails'
gem 'jquery-rails'
group :assets do
gem 'coffee-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'therubyrhino'
gem 'execjs'
end
group :development do
gem 'annotate'
gem 'puma'
end
gem 'dimensions-rails'
gem 'sass-rails', '~> 4.0.0'
group :production do
gem 'rack-cache'
gem 'actionpack-page_caching'
end
请帮助我理解我做错了什么。