How to Increase Performance in Rails: the stale? method

Editor-in-chief, SitePoint & Learnable

On his last appearance on Talk With the Experts, SitePoint’s developer Mal Curtis was asked about performance issues on Ruby on Rails apps and ways to increase speed. One of his suggestion was to use the stale? method, a sometimes underused function in Rails that can, out of the box, do a very good job of automatically reducing perceived latency.

In a nutshell, the stale? method prevents rendering of an entire template when there is no need to. Rails and the browser handle everything correctly for you as a status 304 (not modified) is returned instead a normal status 200.

Mal has put the video below together to show, in 3 minutes, how to use the stale? method on its most basic form to increase speed on a Ruby on Rails app. Great tip.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • http://doelsengupta.blogspot.in doel

    Thanks for posting this, never knew stale? is so useful :)