Coder Social home page Coder Social logo

Page caching? about comfortable-mexican-sofa HOT 6 CLOSED

comfy avatar comfy commented on August 24, 2024
Page caching?

from comfortable-mexican-sofa.

Comments (6)

GBH avatar GBH commented on August 24, 2024

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..

from comfortable-mexican-sofa.

ramieblatt avatar ramieblatt commented on August 24, 2024

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:insend'
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:insend'
activesupport (3.0.3) lib/active_support/callbacks.rb:93:in run_callbacks' actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:inprocess_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:ininstrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in instrument' activesupport (3.0.3) lib/active_support/notifications.rb:52:ininstrument'
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:inprocess_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:inperform_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:inperform_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:inprocess'
actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in process' actionpack (3.0.3) lib/action_controller/metal.rb:138:indispatch'
actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in dispatch' actionpack (3.0.3) lib/action_controller/metal.rb:178:inaction'
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:indispatch'
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:incall'
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:inoptimized_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:incall'
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:incall'
hoptoad_notifier (2.3.0) lib/hoptoad_notifier/rack.rb:27:in call' warden (1.0.3) lib/warden/manager.rb:35:incall'
warden (1.0.3) lib/warden/manager.rb:34:in catch' warden (1.0.3) lib/warden/manager.rb:34:incall'
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:incall'
rack (1.2.1) lib/rack/methodoverride.rb:24:in call' actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:incall'
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:incall'
actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:in call' activerecord (3.0.3) lib/active_record/query_cache.rb:32:incall'
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:incache'
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:incall'
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:incall'
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:incall'
railties (3.0.3) lib/rails/rack/logger.rb:13:in call' rack (1.2.1) lib/rack/runtime.rb:17:incall'
rack (1.2.1) lib/rack/lock.rb:11:in call' rack (1.2.1) lib/rack/lock.rb:11:insynchronize'
rack (1.2.1) lib/rack/lock.rb:11:in call' actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:incall'
railties (3.0.3) lib/rails/application.rb:168:in call' railties (3.0.3) lib/rails/application.rb:77:insend'
railties (3.0.3) lib/rails/application.rb:77:in method_missing' thin (1.2.7) lib/thin/connection.rb:76:inpre_process'
thin (1.2.7) lib/thin/connection.rb:74:in catch' thin (1.2.7) lib/thin/connection.rb:74:inpre_process'
thin (1.2.7) lib/thin/connection.rb:57:in process' thin (1.2.7) lib/thin/connection.rb:42:inreceive_data'
eventmachine (0.12.10) lib/eventmachine.rb:256:in run_machine' eventmachine (0.12.10) lib/eventmachine.rb:256:inrun'
thin (1.2.7) lib/thin/backends/base.rb:57:in start' thin (1.2.7) lib/thin/server.rb:156:instart'
thin (1.2.7) lib/thin/controllers/controller.rb:80:in start' thin (1.2.7) lib/thin/runner.rb:177:insend'
thin (1.2.7) lib/thin/runner.rb:177:in run_command' thin (1.2.7) lib/thin/runner.rb:143:inrun!'
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

from comfortable-mexican-sofa.

ramieblatt avatar ramieblatt commented on August 24, 2024

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

from comfortable-mexican-sofa.

GBH avatar GBH commented on August 24, 2024

Re-opening... and that's a really bizarre error. Googling for something similar just gives a StackOverflow question with no solution.

from comfortable-mexican-sofa.

ramieblatt avatar ramieblatt commented on August 24, 2024

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 }

from comfortable-mexican-sofa.

GBH avatar GBH commented on August 24, 2024

Closing as it's a duplicate of #64 now.

from comfortable-mexican-sofa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.