Forum: Rails deployment Intermittent page loads in Ruby on Rails app

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
67df5b7ef41bb06c2ca5fa27e7518ae3?d=identicon&s=25 Vaughan M. (vaughan)
on 2011-08-24 00:43
Hi Everyone, this one's got me stumped.

I've got a ruby on rails site here (rails 2.0.2, ruby 1.8.6, running on
thins (0.8.2) sitting on top of nginx), and when I hit a certain action
I sometimes get the correct response, other times I get a 500 error.

The code in this view goes as follows:

def show
  @item = Item.find_by_url_slug(params[:id])

  filename = "#{RAILS_ROOT}/public/#{@item.index.url}"
  @data =, 'rb') { |f| } # read data via File.

  render :layout => false

The view is rather simplistic, with show.html.erb containing

<%= @data %>

I've suspected caching, and have tried setting a variety of different
headers (cache-control, expires etc), and also tried the expires_now()
method, to no avail.

Out of interest I've also tried adding a sleep(2) call in the
controller, and looking at the network requests it's obvious on the 500
pages that this method isn't being called - none of the above code in
the show action is.

Furthermore, there's no evidence of the call in the production.log when
the page doesnt load, or any errors in the nginx log. So, no errors to
debug, just the occasional 500 (happening say 2/4 page loads).

I should add that this code works fine locally, and on our staging
server - it's only in production that this is an issue.

Any ideas??
This topic is locked and can not be replied to.