To begin with, for people who are not familiar with CDN
What is CDN ? (Wikipedia definition) A content delivery network or content distribution network (CDN) is a large distributed system of servers deployed in multiple data centers across the Internet. The goal of a CDN is to serve content to end-users with high availability and high performance. CDNs serve a large fraction of the Internet content today, including web objects (text, graphics and scripts), downloadable objects (media files, software, documents), applications (e-commerce, portals), live streaming media, on-demand streaming media, and social networks.
There are many ways to serve static assets for your awesome cool website. You can buy a CDN, host it on a costly hosting service, use github pages or just use google app engine and take advantage of the cloud storage.
Create you first Google app engine project
Since google appengine works on
go(Expiremantal) programming language, make sure that any one of those works on you machine.
Download the Google App Engine SDK from the following URL that suits your Operating system https://developers.google.com/appengine/downloads After downloading install app engine sdk on you machine.
Sign up for Google App Engine at https://appengine.google.com. For this you need a Google account (your GMail address for example, if you dont have one it is free to create one)
Create a new app engine application by clicking on the
Create new Applicaitonbutton on the landing screen.
Create a static html project, you can use the html5 boilerplate or any other front-end seed project that you like. In my case I created the folders and files maually. Add a file and name it as
app.yaml, now this make your app-engine project complete.
Open up the project in your favorite editor and copy paste pastes the following snipped.
Now upload image files to images folder and any other resources to files folder. You can create any number of folder and make sure you mention that folder path as a
static_dirin app.yaml file.
Once you completed copying all the static file, now we need to deploy to the google cloud. The easiest way is to use the
GoogleAppEngineLauncherwhich will be come with the SDK. Add a project to the launcher by clicking on the
+button. Alternatly you can just drag and drop the project folder on to the Launcher.
Select a project and click on run to test your project locally. If you feel everything works fine click on the
Deploybutton to deploy the application. Give your Google account user name and password and sign in. or you can fire up the terminal and cd to the project directory and use this command
appcfg.py update .
Once the deployment is successful you can access your static files like this http:// < app name >.appspot.com/images/brand.png
Though, Google Appengine is awesome there are some limitations for the free accounts
- Google App Engine does not support any data structure that is larger than 1MB in size.
- Quota limitations. more details in documentation
- Aral Balkan wrote a post discussing these defects of app engine — http://aralbalkan.com/1504/
- Nice article on how to use Google app engine as your own CDN — http://24ways.org/2008/using-google-app-engine-as-your-own-cdn/