Best way to serve static content

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?

Thanks!

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.

1 Like

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.

Why not just write a RewriteRule for your http server?

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)

Thanks!

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 (GitHub - AssetSync/asset_sync: Synchronises Assets between Rails and S3) which will upload all of your static assets to S3 or Rackspace CDN.

1 Like