Working with Heroku, Jekyll and Sinatra
Ok, I’ve changed my mind and tweaked this site into a blog. Will I write it regularly? Only time will say.
Anyway, I was playing with Heroku to evaluate the feasibily of using it to host a small site generated by Jekyll.
Why bother?
There are already at least a couple of solutions, namely Rack-Jekyll and a blog post which explains how to use Sinatra. I see problems with both of them:
-
Rack-Jekyll does not set any HTTP cache header, so every request will hit the dyno;
-
the blog post was written before Sinatra 1.0, and with this latest release it does not work perfectly because Sinatra does not apply filters to requests for static assets anymore, so the HTTP cache header is not set.
And now?
The possible solutions:
-
stick with Sinatra pre-1.0 and follow the blog post;
-
still follow the blog post but turn off the management of static assets by Sinatra 1.0 and handle them manually with a big splat argument route:
-
put the product of Jekyll in public, let Heroku’s web server handle every request and use Sinatra or plain Rack just to map ’/’ to ‘/index.html’.
Using Sinatra to handle requests allows you to set whatever header you want, so you can set Cache-Control the way you like it; leaving everything to Heroku’s web server will set just the Last-Modified header (at least at the time of this writing). Is it enough? I think the answer is “Yes!”, but your taste is king and having alternatives is always good.