Google spends hundreds of millions of dollars building efficient web serving infrastructure spread throughout the globe. Widget developers can take advantage of this optimized infrastructure to serve widgets quickly to one or a million users. In my last post I discussed best practices for scaling web widget content based on existing browser and Internet technologies. In this post I’ll outline different ways you can take advantage of Google’s architecture to serve your widget content to the world. I’ll cover various depths of integration and their branding and licensing issues.
Hosting your widget content on Google
Google not only serves widget content in its personalized homepage and desktop products, it’s also a web host.
Google Gadgets Editor
The Google Gadgets Editor helps developers build and test new gadgets inside their browser window. Once you are happy with the test results you can save and publish your gadget manifest file directly onto the “google.com” domain.
The Gadgets Editor only saves XML files. Developers with external resources such as images, Flash, or movies, will need to serve those files using a different hosting option.
Google Page Creator
Anyone with a Google account can create new web pages and upload files to their Google Page Creator account. Standard Google accounts can choose their own subdomain at “googlepages.com” and Google Apps customers can add pages and files under their own custom domain.
Add a new site subdomain such as “widgets.example.com” or sign-up for an entirely new domain such as “examplewidgets.com” on the Google Apps website. All of your new content uploaded to Google Pages will be served from Google’s infrastructure under the name you choose.
Google Code Project Hosting
Google hosts projects licensed under an Apache, Artistic, BSD, GPL, GLPL, MIT, or Mozilla open-source license. Google Code Project Hosting manages project collaborations on wikis, bug lists, and version control systems to help your users report issues with their widget or contribute new patches.
If you’re willing to open up your widget licensing and receive built-in community features Google Code Project Hosting may be the right widget hosting platform for you.
Caching remote content
External data requests have an optional parameter,
refreshInterval, that can override Google’s default caching behaviors for all supported widget update data formats. You might lower your refresh interval to 15 to pull updates from a frequently changing data set or extend your refresh to 3600 for content that updates once per week.
Google Gadgets has special handlers for caching and retrieving image files. The
_IG_GetImage method constructs an
img element for any URL for quick insertion into any DOM. The
_IG_GetImageUrl replaces your typical
src attribute with the appropriate location of a cached image on Google’s servers.
Google will cache any URL specified in your code using the
Google Analytics customers can track widget pageviews using their existing software and accounts. You can create a new Analytics profile for each new widget or integrate reporting with your existing website, it’s up to you.
You need to require the Google Analytics library in your gadget manifest to load the appropriate libraries. You can then log new page requests using the
_IG_Analytics method, a passthrough for the
urchinTracker method found in the traditional Google Analytics and Urchin code. You can assign unique page names to each gadget action to track popular activities and use cases.
Popular widget content has the potential to melt your servers but the right code and planning can offload a lot of that burden onto Google’s server farms. Your content will appear on each widget user’s screen faster and with higher availability than you might be able to offer on your own servers. External free hosting and caching also helps you experiment without the fear you might crash your existing boxes.