teslaworksumn/teslaworks.net — pull request #184 by tylrtrmbl (2013-11-24 00:25:21+00:00)
Title: Use Amazon CloudFront for static hosting

- Adds a function for generating a CDN URL from a "relative" app URL
- CDN URL uses versioning, which lets us set absolutely massive max-age
- URL util is made available to Jinja

Current testing shows that Amazon CloudFront takes much longer than our own static hosting.

| Our Typical | CF Typical |
|----------------------|-----------------------|
| 500ms | 850ms |

The catch is, I don't think this is __actually__ typical, only typical right now. I think that usually our server gets slammed at certain times of the day and static hosting slows to a crawl. AWS gives us more consistency, at the cost of best-case.

Also snuck in a util function location refactor.

### :warning: Necessary Update Path

Before deploying this, we must:
- Automate or document the process that modified static resources are given a versioned URL prefix and uploaded to S3
- Remove the `/static/` prefixes from our URLs in the database:
- `photo_url` in `projects`, `leaders`, and `project_photos`
- We should come up with a system for deleting old static data to avoid (admittedly tiny) excess storage costs