Closed ramieblatt closed 13 years ago
This made think. Actually page caching for css/js might be incorrect. It works fine if you run a single site from the installation, but it might be a problem if you have multiple. Meaning 'default' layout from site A, will conflict with 'default' layout from site B.
As far as the actual page content goes it's 'cached' on the database. Application doesn't do any parsing of tags and so on, just serves content directly from Db. I think there are only 2 SQL calls to serve a page. Recently I deployed an app with Sofa for a pretty busy site and it was generally completing requests in 15ms or so.
The reason there's no real page caching for cms content is because of possibility of dynamic content served via helpers/partials/etc. But I recognize there's a need for proper caching..
Thanks for your thoughtful answer. I did see that the cms serves the content field from the db after the page is rendered, which works very well, but we are interested in also implementing page caching (i.e. static files served up by apache or nginx without touching the rails app) with some dynamic content via ajax callbacks for some partials (or even server side includes), for e.g. see: http://railscasts.com/episodes/169-dynamic-page-caching
While we do have page caching working with dynamic contant for non cms actions, a simple attempt to add render_html to the caches_page line of cms_content_controller on my fork just blows things up with a hard to trace exception:
NoMethodError in Cms contentController#render_html
undefined method `after' for true:TrueClass
Rails.root: /Users/ramie/heatwave_rails3
Application Trace | Framework Trace | Full Trace
activesupport (3.0.3) lib/active_support/callbacks.rb:314:in send' activesupport (3.0.3) lib/active_support/callbacks.rb:314:in
_callback_after_13501'
activesupport (3.0.3) lib/active_support/callbacks.rb:476:in _run__1625381097__process_action__1055742085__callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:409:in
send'
activesupport (3.0.3) lib/active_support/callbacks.rb:409:in _run_process_action_callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:93:in
send'
activesupport (3.0.3) lib/active_support/callbacks.rb:93:in run_callbacks' actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:in
process_action'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:30:in process_action' activesupport (3.0.3) lib/active_support/notifications.rb:52:in
instrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in instrument' activesupport (3.0.3) lib/active_support/notifications.rb:52:in
instrument'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:in process_action' actionpack (3.0.3) lib/action_controller/metal/rescue.rb:17:in
process_action'
newrelic_rpm (2.13.4) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in process_action' newrelic_rpm (2.13.4) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:252:in
perform_action_with_newrelic_trace'
newrelic_rpm (2.13.4) lib/new_relic/agent/method_tracer.rb:141:in trace_execution_scoped' newrelic_rpm (2.13.4) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:247:in
perform_action_with_newrelic_trace'
newrelic_rpm (2.13.4) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in process_action' actionpack (3.0.3) lib/abstract_controller/base.rb:120:in
process'
actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in process' actionpack (3.0.3) lib/action_controller/metal.rb:138:in
dispatch'
actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in dispatch' actionpack (3.0.3) lib/action_controller/metal.rb:178:in
action'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in call' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in
dispatch'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:27:in call' rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in
call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in recognize' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in
optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in recognize' rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in
call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in call' newrelic_rpm (2.13.4) lib/new_relic/rack/developer_mode.rb:20:in
call'
hoptoad_notifier (2.3.0) lib/hoptoad_notifier/rack.rb:27:in call' warden (1.0.3) lib/warden/manager.rb:35:in
call'
warden (1.0.3) lib/warden/manager.rb:34:in catch' warden (1.0.3) lib/warden/manager.rb:34:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in call' actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in
call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in call' actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:in call' actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:149:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:in call' activerecord (3.0.3) lib/active_record/query_cache.rb:32:in
call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in cache' activerecord (3.0.3) lib/active_record/query_cache.rb:12:in
cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:31:in call' activerecord (3.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:in call' activesupport (3.0.3) lib/active_support/callbacks.rb:415:in
_run_call_callbacks'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in call' rack (1.2.1) lib/rack/sendfile.rb:107:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in call' actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in
call'
railties (3.0.3) lib/rails/rack/logger.rb:13:in call' rack (1.2.1) lib/rack/runtime.rb:17:in
call'
rack (1.2.1) lib/rack/lock.rb:11:in call' rack (1.2.1) lib/rack/lock.rb:11:in
synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in call' actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in
call'
railties (3.0.3) lib/rails/application.rb:168:in call' railties (3.0.3) lib/rails/application.rb:77:in
send'
railties (3.0.3) lib/rails/application.rb:77:in method_missing' thin (1.2.7) lib/thin/connection.rb:76:in
pre_process'
thin (1.2.7) lib/thin/connection.rb:74:in catch' thin (1.2.7) lib/thin/connection.rb:74:in
pre_process'
thin (1.2.7) lib/thin/connection.rb:57:in process' thin (1.2.7) lib/thin/connection.rb:42:in
receive_data'
eventmachine (0.12.10) lib/eventmachine.rb:256:in run_machine' eventmachine (0.12.10) lib/eventmachine.rb:256:in
run'
thin (1.2.7) lib/thin/backends/base.rb:57:in start' thin (1.2.7) lib/thin/server.rb:156:in
start'
thin (1.2.7) lib/thin/controllers/controller.rb:80:in start' thin (1.2.7) lib/thin/runner.rb:177:in
send'
thin (1.2.7) lib/thin/runner.rb:177:in run_command' thin (1.2.7) lib/thin/runner.rb:143:in
run!'
thin (1.2.7) bin/thin:6
/Users/ramie/.rvm/gems/ruby-1.8.7-p174@rails3/bin/thin:19:in `load'
/Users/ramie/.rvm/gems/ruby-1.8.7-p174@rails3/bin/thin:19
Request
Parameters:
None Show session dump
Show env dump
Response
Headers:
None
Argh! ^&%&^% github UI this is not the first time I closed an issue when all I wanted was to add a comment. Can you re-open so others can comment?
Thanks, Ramie
Re-opening... and that's a really bizarre error. Googling for something similar just gives a StackOverflow question with no solution.
I think I found the issue which would break any of the page caching for css or js, see pull request. You need to pass a Proc on the :if option of caches_page. That is:
, :if => Proc.new { |c| ComfortableMexicanSofa.config.enable_caching }
Closing as it's a duplicate of #64 now.
Love the sofa! We need to implement a page caching scheme with our sofa based cms; i.e. like Rails page caching. I see that you did a basic Rails page caching for the CSS and JS, but what about caching for pages? Any plans for that? We are hesitant to fork a very active repo.