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.

render :file caches contents - doesn't reload until webserver reloaded

#4449

Ran into this issue when upgrading a 2.1.2 app to 2.3.5.

I had a controller that was using render :file to show a CSS document.

In 2.1.2 I could edit that document, reload, and see the changes that happened. Under 2.3.5 the same code refuses to reload the document unless Rails/passenger is restarted. I was forced to use "render :text => File.read(file)" instead of render :file.

The new behavior is confusing.

Reported by subimage · April 21st, 2010 @ 04:16 PM

State: invalid
Milestone: 2.3.6
Assigned to: nobody
Importance: Low

Activity

  1. Rizwan Reza
    Rizwan Reza
    • Milestone set to 2.3.6
    • Tag changed from cache, caching, file, render to bugmash, cache, caching, file, render

    May 15th, 2010 @ 03:52 PM

  2. Diego Algorta
    Diego Algorta
    • Tag changed from bugmash, cache, caching, file, render to bugmash, cache, caching, file, not, render

    not reproducible

    I tried with 2-3-stable branch and I was able to update my template file and see the changes in the browser without needing to restart the app.

    May 15th, 2010 @ 06:25 PM

  3. Rizwan Reza
    Rizwan Reza
    • State changed from new to invalid

    May 15th, 2010 @ 06:26 PM

  4. Aaron Hamid
    Aaron Hamid

    Diego, was it a file with a .css extension?

    May 15th, 2010 @ 09:18 PM

  5. Aaron Hamid
  6. Rizwan Reza
    Rizwan Reza
    • Tag changed from bugmash, cache, caching, file, not, render to cache, caching, file, not, render

    May 16th, 2010 @ 02:07 AM

  7. heldopslippers
    heldopslippers

    It is reproducible.
    I have te same problem. Running in development mode. And rendering a css file. When changing the file rails does not pick up on it.

    I have to say though that I am using it with an action (for very good reasons).

    so for example I have this line of code in my application controller:

    def css
      render :file => "#{RAILS_ROOT}/clients/#{client_id}/index.css", :layout => false
    end
    

    I am by the way running v 2.3.8
    And really don't know if this helps (first time) But I hope it does!

    June 22nd, 2010 @ 03:30 PM

  8. dxg
    dxg
    • Importance changed from to Low

    Have exactly the same problem.
    Rails 2.3.9, ruby 1.9.1p429, i686-linux, development mode, using 'script/server'

    <%= render :file => Rails.root.to_s + '/app/views/ab_mailer/newsletter.html.erb' %>
    

    September 24th, 2010 @ 06:28 AM

  9. Damon Cali
    Damon Cali

    Same problem.

    Rails 2.3.5, Ruby 1.8.7-p302, Snow Leopard, development env, WEBrick 1.3.1

    November 3rd, 2010 @ 03:36 PM

  10. obregoru
    obregoru

    I have this same problem - to get around it, I'm currently using the render :text => File.open as recommend above, but this method but this is much slower in terms of performance.

    I have html files in /public which has content that is changed regularly. I would like to be able to have the file cached, yet, be able to update or invalidate the cache on a timed/regular basis so that the file reloads and is rendered via render :file..

    Using file open along with my own cache of file contents may work well in the short run, but really - what is the answer here??

    December 16th, 2010 @ 06:05 PM

  11. Paintrick
    Paintrick

    I have the same issue in 3.0.4..
    could it be a proxy cache or something
    or is it really Rails caching the render :file part?

    Also, when I open the rendered file in another browser tab
    but then without rails, I see the latest content.

    how does this work / happen?
    thanks!

    February 25th, 2011 @ 12:32 PM

  12. tsailipu
    tsailipu

    Same in 3.0.5. I do know that this behavior doesn't happen in development mode and only on production mode.... Is there a way for us to clear in the code whatever is being cached?

    March 25th, 2011 @ 08:45 PM