Get Definitive Thesis Theme Video Tutorials for FREE! Click here for details

A Beginner’s Guide to Google Gears

by Ashwin

in Web 2.0

 

Many of us know about Google Gears as Google’s innovation to store web data offline, that can be viewed even in the absence of an Internet connection.  But Gears is much more than that.

What is Google Gears?

Gears is an open source project that enables more powerful web applications, by adding new features to your web browser. (as described by Google).

In other words, Gears enables web applications to use some features like local data storage,   natural interaction with desktop etc., that were enjoyed primarily by Desktop based applications.

What are the features of Google Gears as of version 0.4?

Local Server Module

This module enables web application to cache HTTP resources like images locally and serve them without requiring a Network connection. 

Applications manage the cache using two classes – ResourceStore and ManagedResourceStoreResourceStore is for caching ad-hoc URLs using Javascript and ManagedResourceStore is for caching set of URLs declared in the “manifest” file and updated automatically

The Local Server intercepts all HTTP/HTTPS requests and serves them when all of the following conditions are met:

  • URL is cached in ResourceStore or ManagedResourceStore
  • Store’s enabled attribute is set to “true”
  • If the Store has a “requiredCookie” attribute, then the request must have a cookie that matches

The enabled attribute determines – whether the resources are served locally or from remote server, when the network connection is available.  To read more on the Local Server Module – you can go here

Database Module

Another powerful feature of Gears is the ability to access the Database on the desktop.  This can greatly improve application performance, as database access plays a major role in network latency. 

Database Module provides an API, that enables the Javascript to store browser-local data storage onto the Database.  Gears uses the SQLite database.

Security is ensured by making sure that the web application cannot access data outside of its domain.  A web page with a particular scheme, host and port can access only resources with the same scheme, host and port.   Thus, a site using Gears:

  • Can access only databases created for that site’s origin
  • Can only cache URLs and use manifests from the site’s origin  

Data storage and retrieval follows regular SQL statements – thus there is no learning curve here.  To know more about the Database API, reach here

WorkerPool Module

This API allows web applications to run heavy and long running Javascript code in the background, without blocking the main page’s script execution, mimicking the background processes in Unix.

I/O operations and heavy computations are some sample operations, that can be optimized using WorkerPool API. 

WorkerPool is a collection of processes; and not threads.  Thus, they don’t share namespace or execution state.  These processes are independent of each other and interact by sending message objects.  Also, the workers do not inherit script code from their parents.  To know more about the WorkerPool API, reach here

New in 0.4

  • Geolocation API, that provides access to user’s geographical location
  • Blob API for handling blocks of Binary data.  This is particularly useful for caching images.  We can expect an implementation on Picasa
  • Access to files on the client machine through Desktop API.  Comes handy for document management web sites, where online documents can be stored on local disk for offline access.  Also useful for providing Desktop shortcuts for web applications
  • Localization of Gears to 40 languages

With Chrome now out of the box, we can expect more enhancements with Google Gears.  It is a great leap towards making Operating Systems redundant on the desktop.


To know more about Google Gears – http://code.google.com/apis/gears/

Hope you found this article useful.

Technorati Tags: google gears,google api,web 2.0
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    blog comments powered by Disqus

    Previous post:

    Next post: