← Back to Upcase

Best way to serve static content

(Sean Yu) #1

Hi there,

I have a rails powered webapp that I recently refactored into an API, and a pure html/css/js website. Given that my website is now completely independent of my backend (besides expecting the api to work of course), what is the best way to serve it? Should I take the static files and drop them into my rails app, or serve it from something else entirely?


(Adarsh Pandit) #2

If everything is client-side (e.g. no database), I would consider serving the site using an Amazon S3 bucket.

Here is their getting started guide.

Rails (or other frameworks feel like overkill and your static site response time will likely be much better on S3.

(Erik Guzman) #3

If you want to serve up static pages without having to build out controllers and routes you can looking into high_voltage gem from thoughtbot, built exactly for serving up static content.
No fuss solution until you decide on your next step.

As a side note I was also thinking if you wanted to speed up load times you could look into cacheing your pages.

(Don Hill) #4

Why not just write a RewriteRule for your http server?

(Sean Yu) #5

high_voltage’s github page specifically mentions pages such as ‘About Us’, etc. Is it also good for javascript heavy applications (I’m not sure if there’s a different between serving a a bunch of static js, vs pure html/css)


(Harlow Ward) #6

I think high_voltage would be a good place to start. The big benefit is you still get to use the Asset pipeline that rails provides for us – This will minimize any JS, CSS, etc on the fly.

I’d also recommend using the asset_sync gem (https://github.com/rumblelabs/asset_sync) which will upload all of your static assets to S3 or Rackspace CDN.