🔨 Static Sites with Ruby on Heroku/Cedar
Ruby CSS JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
public Add some static assets Jul 21, 2012
Gemfile secure source URI May 9, 2013
Gemfile.lock Add Gemfile 🔒 :trollface: Jul 21, 2012
README.md Typo in README.md Aug 2, 2014
config.ru Append / to css Jul 21, 2012


This article was forked from Marshall Huss's Bamboo stack article and updated by Lee Reilly. Lee is a toolsmith and master pintsman hacking on GitHub Enterprise.

Static Sites with Ruby on Heroku/Cedar

Sometimes you just have a static website with one or two pages. Here is a simple way to host your static site and cache it on Heroku using a Rack app.

Your folder should be organized like this:

- MySite
  |- config.ru
  |- Gemfile
  |- public
    |- index.html
    |- images
    |- js
    |- css

In Gemfile file add the following:

source :rubygems

gem 'rack'

You should use bundler to generate the Gemfile.lock file:

  remote: http://rubygems.org/
    rack (1.4.1)



In config.ru file add the following:

use Rack::Static,
  :urls => ["/images", "/js", "/css"],
  :root => "public"

run lambda { |env|
      'Content-Type'  => 'text/html',
      'Cache-Control' => 'public, max-age=86400'
    File.open('public/index.html', File::RDONLY)

This assumes that your template uses relative references to the images and stylesheets. Go ahead and deploy the app. If you are not sure how to deploy to Heroku check out the quickstart guide.

And there you go, a static site being served on Heroku completely cached and easily served using a single dyno.

If this article is incorrect or outdated, or omits critical information, please let us know. For all other issues, please see our support channels.