Getting Started

A short introduction to enabling an application to work offline using Gears.

Contents

  1. Getting Started
  2. Nuts and Bolts: Detecting and Installing Gears

Getting Started

First, if you haven't already, install Gears on your computer to be able to use the sample applications and tools.

Going Offline

The first thing you need to run a web application offline is the ability to start it without an Internet connection. This is the purpose of the LocalServer module.

For a fast introduction to taking web content offline, work through the tutorial Enabling Static Files to Work Offline using Gears. You will be introduced to the LocalServer API and the manifest file, the key components that cache your application's resources and make it available offline.

Storing User's Data

Applications that are more than just static files have data that is typically stored on the server. For the application to be useful offline, this data must be accessible locally. The Database module provides a relational database for storing data. On the Architecture page you will find a discussion of strategies for designing the local storage that your application needs.

When an offline application reconnects, you will need to synchronize any changes made in the local database with the server. There are many different approaches to synchronizing data, and there is no single perfect approach. The Architecture page describes some strategies for synching.

An additional feature of the Gears database is Full-Text Search, providing a fast way to search text within a database file. Read the details here.

Performance

When synchronizing large amounts of data, you may find that the database operations begin to affect the responsiveness of the browser. The WorkerPool allows you to move your database operations to the background to keep the browser responsive.

The WorkerPool is useful for any expensive operations that slow down the UI.

Next Steps

Check out the Resources and Tools page to download useful files and sample applications.

See the FAQ to find answers to common questions. And finally, we invite you to participate in the Developer Forum for Gears.

Nuts and Bolts: Detecting and Installing Gears

Your web application needs to detect whether or not Gears is installed on a user's system before calling the APIs, and also to determine when to display an installation prompt to the user.

Always initialize Gears using gears_init.js . If Gears is installed, then google.gears will be defined. If Gears isn't installed, you can direct the user to a customized installation page, as shown below.

Note: Always use gears_init.js to access Gears. Other uses may not be supported in the future.

<script src="gears_init.js"></script>
<script>
  if (!window.google || !google.gears) {
    location.href = "http://gears.google.com/?action=install&message=<your welcome message>" +
"&return=<your website url>"; } </script>

Use the URL in the code above to access the Gears installation page. Substitute your customized message and your URL in the parameters.

Parameters