Skip to content
Make full use of Nginx Server Side Includes quickly and easily in your Rails 3 app
Find file
Latest commit 1f5a9aa Nov 7, 2010 @seenmyfate bumped version
Failed to load latest commit information.
app initial commit Nov 7, 2010
.gitignore initial commit Nov 7, 2010
Gemfile initial commit Nov 7, 2010
LICENSE initial commit Nov 7, 2010 initial commit Nov 7, 2010
Rakefile bumped version: Nov 7, 2010
VERSION Version bump to 0.0.4 Nov 7, 2010
simple_ssi.gemspec bumped version Nov 7, 2010


Make full use of Nginx Server Side Includes quickly and easily in your Rails 3 app. First up require the gem in your Gemfile:

gem 'simple_ssi'

Turn on server side includes in nginx

location / {
  ssi on;

In your view, use the helper to specify the action you want to include:

<%= ssi :controller => 'users', :action => 'notifications' %>

Nginx will now include the HTML created by your action in the page dynamically, so you can cache the rest of the page and still include user specific information.

The example above assumes that you have something along these lines in your application:

class ApplicationController < ActionController::Base

  def current_user
    #some kind current user method

class Users < ApplicationController
  def notifications
    @notifications = current_user.notifications


<% for notification in @notifications %>
    <%# do stuff%>
<% end %>


match '/users/notifications' => 'users#notifications'

If you want to keep your ssi action separate, and you don't want to have to add a new route everytime, run the simple_ssi generator:

rails g simple_ssi

Now simply add any methods to app/controllers/ssi_controller.rb, add a view under app/views/ssi and pass the method name to the helper:

<%= ssi :notifications %>

To do:

  • Better readme
  • Example app
  • Benchmarks
  • Apache support

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright (c) 2010 seenmyfate. See LICENSE for details.

Something went wrong with that request. Please try again.