Javascript is cached in development mode with asset pipeline

后端 未结 8 990
感动是毒
感动是毒 2021-02-07 07:53

I recently upgraded my application to rails 3.1 and generally everything seems to be working but one thing is driving me insane.

I have 2 main js files, we\'ll call the

相关标签:
8条回答
  • 2021-02-07 08:33

    Have a look at your development log and see what it says when the application.js is served.

    It should look something like this for a normal request (you browsed to a page):

    Started GET "/assets/application.js" for 127.0.0.1 at Fri Sep 30 12:13:27 +1300 2011
    Served asset /application.css - 304 Not Modified (2ms)
    

    If not you may have not set the pipeline options correctly. One of the production settings might be in the wrong place. Section 9 of the asset pipeline guide has a checklist of correct settings for a migrated app.

    0 讨论(0)
  • 2021-02-07 08:39

    Also note that if you enable config.threadsafe, it will turn cache_classes on. So if your config/environments/development.rb file contains the following:

    config.cache_classes = false
    config.threadsafe!
    

    Then you are turning off cache_classes and then turning it right back on. You will need to either comment out config.threadsafe (if you don't need it) like this:

    config.cache_classes = false
    # config.threadsafe!
    

    Or, if you need threadsafe, reverse the order of these two configurations so that config_classes is really turned off:

    config.threadsafe!
    config.cache_classes = false
    

    For more information, see http://tenderlovemaking.com/2012/06/18/removing-config-threadsafe.html

    0 讨论(0)
  • 2021-02-07 08:41

    I had the same issue, config.action_controller.perform_caching set properly. I also use Heroku and precompile assets for the Push to Heroku using: RAILS_ENV=production bundle exec rake assets:precompile After the push, when I started new work, I forgot to remove the precompiled assets using: sudo rm -r public/assets/*

    So, no matter what I did to any of my .js files, they changes were not showing up.

    0 讨论(0)
  • 2021-02-07 08:44

    If above mentioned answers fail in your context..

    make sure the caching is done by rails.. some times it does not detect changes in asset and serve the older cached version..

    use rails c >> Rails.cache.clear
    or simply delete the caches in tmp dir

    [project_dir/tmp/cache/assets"]

    0 讨论(0)
  • 2021-02-07 08:49

    I had the same issue and found that removing the asset digests in development fixed the issue. Make sure you set it to false in developmen.rb:

    config.assets.digest = false
    
    0 讨论(0)
  • 2021-02-07 08:52

    Opening Chrome in incognito mode worked best for me. No need to open and close a tab. In incognito mode, chrome doesn't cache javascript.

    0 讨论(0)
提交回复
热议问题