Sunday, February 24, 2008

Google Gears API: LocalServer Module

Following my last post about Google Gears Database Module , here comes the LocalServer module.

LocalServer module allows you to store the HTTP resources locally. The resources could be images, html pages, css, JS files etc. For more details refer my post on Gears Modules.

There are two options in LocalServer to store the files:

1. ManagedResourceStore: The resources are cached based on a manifest file. Set of URLs of the resources has to mentioned in a manifest file with a version number of the manifest file. When ever the resource is modified, you need to change the version number specified in the manifest file. Gears will take care of updating the local store (resources stored locally) with the new version. This option is more handy when the resources are almost static or occasionally modified, and thus avoiding downloading the resources every time you go offline/online.

Note: You might have an array of resources of which only few might have been modified. Gears will download only the modified resource.

2. ResourceStore: Alternately you can store the resources through API (method calls) at will, using methods like capture(), copy(), remove() etc.

Well, selecting the option is purely based on the requirement and the type of resource. If the resource is almost static, then you could use the ManagedResourceStore option, however there are resources associated with UI themes which changes based on user's current settings, that could be captured using ResourceStore.

Fore more details refer: http://code.google.com/apis/gears/api_localserver.html

In my next post I'll explain ResourceStore module with sample code.

No comments: