Render :file cached?

In my application I have a controller/view that displays the contents
of an audit log file

def audit_log
render :layout => ‘table’, :file => AUDIT_LOG
end

The audit log is updated frequently but the render call does not re-
read the file so it gets stale. Is there a way to tell render to
check the file timestamp and reload as needed?

On Oct 28, 2:53 pm, Tony [email protected] wrote:

In my application I have a controller/view that displays the contents
of an audit log file

def audit_log
render :layout => ‘table’, :file => AUDIT_LOG
end

The audit log is updated frequently but the render call does not re-
read the file so it gets stale. Is there a way to tell render to
check the file timestamp and reload as needed?

Just posting some notes in case someone else runs into this.

It looks like caching happens when a layout is specified
(for :text, :file and :inline). I wanted my layout so I’m off to try
something new. :-\

from action_view/base.rb
def _render_with_layout

if (options[:inline] || options[:file] || options[:text])
@cached_content_for_layout = @content_for_layout
render(:file => partial_layout, :locals =>
local_assigns)

On Oct 28, 4:28 pm, Tony [email protected] wrote:

read the file so it gets stale. Is there a way to tell render to

if (options[:inline] || options[:file] || options[:text])
@cached_content_for_layout = @content_for_layout
render(:file => partial_layout, :locals =>
local_assigns)

So…the solution is to just open the file directly instead of using
render.

<%= File.read(AUDIT_LOG) %>

I’ll probably cache it in the controller and only let it be updated
once every X minutes.