Need to host a file like an image and want it hosted on a CDN (Content Delivery Network)? Check out RawGit. It's free.

All you need is a GitHub account. Just upload the file to a repository, go to RawGit, enter the URL in the wide box at the top, and the page constructs two URLs for you.

Use the "Production" Option for CDN

I recommend using the Production option as much as possible since it doesn't place a burden on the guy paying the bills. The Production version uses MaxCDN but has the drawback that it will never update content once it is cached.

So to avoid problems with being able to make updates, you need to make sure your URL for your file is as version specific (commit specific) as possible. That's why you need to use a URL with a commit hash that will change if you commit a new file. Here's an example of how to get such a URL from GitHub:

RawGit Animated GIF

The animated GIF above is being hosted in the same manner and I used the same procedure to set up CDN hosting for it.

Once you have that URL just go to RawGit to use the URL calculator or, even easier, just manually replace with in the URL.

Here's a shell script that will create the URLs. Probably easier than the above. Works in "gitbash" in Windows, and should work in all other bash shells:

Make sure that your current working directory is the root of the repo and then run it like ** for example to recurse through all files (assuming your bash has the "globstar" feature).

Development RawGit

This uses a proxy with limited resources so don't use it for anything that will be viewed by more than you or someone who is helping you. For this you replace with (leave off the cdn. on the front) and you don't need to worry about permanent caching of your files. So, you can skip including a commit hash.

But I would avoid this option as much as possible. Don't use it unless you're working on something, need the proxy to fix the content-type headers, and need to do lots of updates or something. And again, don't publish any pages that use such URLs or the guy's proxy will get hammered. He doesn't want that.