1

We recently migrated an older Rails 2.3 website from a CentOS 6 server to CentOS 7 server. Since that transition, a few pages are getting cached that shouldn't be.

Here are the details on the web server changes:

  • The old system was Passenger 4.x, the new is Passenger 5.0.30.
  • The old system was Apache, the new is Nginx 1.10.1
  • The app has not been changed, other than adding the config.ru for Passenger 5
  • We are running Rails 2.3.17 on Ruby REE
  • We are running Memcached for some fragment caching, but not with these pages.

Things we have tried:

  • If we modify the view, the changes do not show up until restart. The view template is cached.
  • We disabled Passenger 5's turbocache. It did not help.
  • We removed all keys from Memcached. It did not help.
  • Find and delete on disk Rails caches – we didn't find any (and shouldn't).

More details:

  • We host several other Rails 2.3 websites and dozens of Rails 3.x/4.x sites and do not have this issue.
  • If you restart Nginx or touch tmp/restart.txt the changes show up.
  • The log files for Nginx show a 200
  • The production Rails log file shows times for db and view creation.

It looks like it is generating the output, but then it pulls from some kind of cache between Rails, Passenger and Nginx.

What could be causing this?

9
  • Do you modify views directly in production, not going through the "full" deploy process (a step of which is to bounce the app server)? And this works for your other apps? Sep 20, 2016 at 20:41
  • What kind of changes are being held back? I've had a similar issues in Rails 2.x model relationships where has_many or similar relationships cache in the state they were when the webserver was started (as if the db itself was being cached, though it wasn't).
    – Nick Barth
    Sep 20, 2016 at 20:57
  • @SergioTulentsev We modified the views without a full deploy or bouncing the server. I suspect those are being cached by view template caching. Sep 21, 2016 at 15:59
  • @NickBarth - Changes are made to the database that are not showing up. These are pulled through complex relationships, similar to what you describe. What I find odd is that this did not happen on the previous system (also REE). It's also only happening on two specific pages. Sep 21, 2016 at 15:59
  • 1
    @GregBenedict I was running nginx when this happened to me, so maybe that's a clue? I can't say why nginx might cause that behavior, but that and Rails 2.x seem to be the only crossover from our situations. Moving the relationship from a has_many to an instance method (with the same name for easier conversion elsewhere) cleared it up.
    – Nick Barth
    Sep 22, 2016 at 14:57

1 Answer 1

0

This turned out to be a scope that was calling DateTime.now that was not wrapped in a proc - Proc.new { DateTime.now }.call. This causes the date to be cached along with the model.

Why it didn't cache under the old setup, I'm not sure. Maybe it just restarted more often so we never saw it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.