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.

ActionView::Base.computed_public_paths cacheing not consistent with ActionController::Base.perform_caching = false

#1233

In essence:

  • I load a page (in development mode) - it looks pretty
  • I change the CSS file some
  • I go back to the browser and hit "refresh"
  • My CSS change doesn't take effect. The browser is using a completely cached version of the css file.
  • I restart my web server
  • I refresh the browser
  • The CSS change takes.

This all happens because ActionView::Base.computed_public_paths effectively caches the timestamp querystring, rendering the timestamped querystring ineffective at forcing the browser to reload a changed asset file.

The following monkey patch fixes the problem:

  unless ActionController::Base.perform_caching
    ActionController::Dispatcher.class_eval do
      before_dispatch :clear_computed_public_paths

      def clear_computed_public_paths
        ActionView::Base.computed_public_paths.clear
      end
    end
  end

Reported by Tim Harper · October 19th, 2008 @ 08:14 AM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. Pratik
    Pratik
    • Assigned user set to josh

    October 19th, 2008 @ 10:02 AM

  2. josh
    josh
    • State changed from new to open
    • Milestone cleared.

    Thats probably the best solution. Can you patch that in the development mode dispatcher callback.

    October 19th, 2008 @ 10:04 PM

  3. Tim Harper
    Tim Harper

    Looks like the internals have changed quite a bit in rails EDGE since 2.1, but the issue still manifests

    Here's my patch, complete with a test:

    http://github.com/timcharper/rai...

    I also tested this by hand to verify that this commit causes timestamps to update automatically in asset urls, and, it does, just like grandma used to make it.

    October 20th, 2008 @ 07:25 AM

  4. Repository
    Repository
    • State changed from open to resolved

    (from [fcb45e5ec3c8ab7b11391c0639609918876ddbb2]) Ensure ActionView::Helpers::AssetTagHelper::AssetTag::Cache is cleared before loading so changes to asset files are picked up by the broswer [#1233 ActionView::Base.computed_public_paths cacheing not consistent with ActionCon... state:resolved]

    Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    October 20th, 2008 @ 07:22 PM

  5. salil
    salil

    i am new to ruby i am facing the same problem as TIM.i changing my css files and images used in a css but my html page not changes because of cache. i don't know where to use above code. i.e. unless ActionController::Base.perform_caching

    Thanks

    IF YOU ASK YOU FOOL FOR 15 min. but IF YOU Don't YOU 'll b FOOL FOREVER.

    February 25th, 2009 @ 03:25 PM