Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

config.action_controller.perform_caching is ignored

#4572

I first noticed this issue with Rails 3 beta3.
Even if you set

config.action_controller.perform_caching = false

in the environment, the configuration is always ignored and defaults to true.
The result is that Rails always tries to perform page/fragment caching, even if you are using the development environment.

If you directly access the ActionController::Base class, it works as expected.

ActionController::Base.perform_caching = false

You can easily reproduce the issue creating a new Rails app with beta3 and running the server or even trying to access the configuration from the console.

I investigated the issue and the guilty seems to be the following ActionController initializer

initializer "action_controller.set_configs"

The configuration value exists in app.config.action_controller but the configuration is never applied to the class on ActionController::Base load.

action_controller/railtie.rb has been recently changed in http://github.com/rails/rails/commit/4163ccec2343ee66e2488f067eab2a...
but the changes doesn't seem to fix the issue.

Reported by Simone Carletti · May 10th, 2010 @ 09:20 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Neeraj Singh
    Neeraj Singh

    I tested it with rails3 edge and am not able to reproduce this issue. I was expecting page caching but I do not see any page cached. This is what I did.

    rails demo
    cd demo
    rails g scaffold User name:string
    rake db:migrate
    rails s

    visit http://localhost:3000/users

    Looked at public directory and I do not see any page cached.

    May 10th, 2010 @ 09:48 PM

  2. Simone Carletti
    Simone Carletti

    The code you posted shouldn't automatically perform page caching, unless you specify cache_pages in your controller.
    However, I switched to rails edge the project and the issue seems to be fixed.

    The ticket can be closed, thank you.

    May 10th, 2010 @ 10:07 PM

  3. Neeraj Singh
    Neeraj Singh

    You are right. I forgot to add cache_pages.

    Anyway it seems it is no more an issue.

    May 10th, 2010 @ 10:10 PM

  4. Jérémy Lecour
    Jérémy Lecour
    • Tag changed from rails 3.0.0.beta3, actioncontroller, perform_caching to rails 3.0.0.beta3, actioncontroller, caching, perform_caching

    Today, I've pulled my hair on something that seems similar.

    I'm working on a Rails 3.0.0.beta.3 app where I want to do some page caching.

    In "Rails.root/config/development.rb" I've put

    config.action_controller.perform_caching = true
    config.page_cache_directory = File.join Rails.root, 'public', 'cache'
    config.action_controller.page_cache_directory = File.join Rails.root, 'public', 'cache'
    

    I've tried two different "page_cache_directory" directives because I've seen both in blog posts, docs, …

    Whatever I put in theses directives, the page cache is written in "Rails.root/public/"

    In the same file, if I write "ActionController::Base.page_cache_directory = File.join Rails.root, 'public', 'cache'" inside or outside the "MyApp::Application.configure" block, it has no effect.

    BUT, if I make an initializer with it, it's working great.

    May 10th, 2010 @ 10:28 PM

  5. Jérémy Lecour
    Jérémy Lecour

    I've tried to install (with bundler) the master branch from Github (http://github.com/rails/rails/commit/446b0ffe1c804f4925867d785b9709...) and it seems fixed.

    The correct directive to put in the environment file is

    config.action_controller.page_cache_directory = File.join Rails.root, 'public', 'cache'
    

    The other one, has no effect.

    There is no need to make a specific initializer.

    May 10th, 2010 @ 10:34 PM

  6. Ryan Bigg
    Ryan Bigg
    • State changed from new to invalid

    Please open another bug for this issue Jérémy.

    May 13th, 2010 @ 11:43 PM

  7. Jérémy Lecour
    Jérémy Lecour

    As I've said, the bug is already resolved. But If you like to have an "history", I can make a new issue that you'll immediately close.

    Thanks

    May 14th, 2010 @ 07:33 AM

  8. mirza
    mirza

    I have the same problem:

    config.action_controller.perform_caching = false
    

    in development.rb is ignored and caching is performed always.

    June 2nd, 2010 @ 07:40 AM