Preventing Auto-Updates of a ManagedResourceStore in Google Gears

The Google Gears LocalServer is lacking one thing -- a way to disable auto-updates of a ManagedResourceStore.


The LocalServer in Gears works well. You simply give it a list of files to store locally and it does so. Any subsequent requests for these files are served by Gears from its own cache and there's no need to be online to open web pages.

The trouble comes when you use a ManagedResourceStore to keep these files locally. Gears "manages" the store by looking for updates to your manifest file whenever any file is requested from the local store and/or at regular intervals. This all works well until you use Gears where it's best suited and where you're most likely to truly go "offline" -- on a mobile device.

When you go offline in a normal desktop-based browser and Gears makes a background request for a URL that can't be realised then it fails gracefully, in that the user isn't aware of it.

When a browser (well, IE Mobile at least) makes this request on a smartphone then the phone takes over and you start to see dialogs popup all over the place. If you're in a low-signal area and the phone's data connections are enabled you'll see something like this:

2009 07 04_11 12 59_0002_111g

If you've switched your phone to "Plane Mode" (hey, maybe you're even working on an actual plane!) then you'll see something like this:

2009 07 04_11 13 45_0004_111g

In both cases you can hide/dismiss and ignore the prompts. For us power users it's no big deal. If you're a typical user who thinks she's offline then anything about failing to connect is bound to cause alarm.

Either way, if you're working offline you really shouldn't be getting prompts about going online.


Pre-empting complaints from my customer about the above problem I set about trying to find a way round it.

My first idea was to switch to an unmanaged ResourceStore. Here you make a one-off call to a Gears method which loads a set of files in to a local store. There's no manifest file and there's no checking to see whether they've updated.

Although an unmanaged ResourceStore seemed just what I wanted, there's one gotcha: they don't let you ignore the query part of the URLs being stored, which is a feature of the manifest files that the system I've been building on Gears relies on.

Without being able to set "ignoreQuery":true for the stored files it just won't work for me, so I had to revert to a managed store.

An Alternate Solution

The next thing I tried was, what I thought to be, a clever little hack whereby I played Gears at its own game. The idea being to make a local cache of the manifest file itself, thereby stopping any request for it from trying to force the phone online. To do that I added some code to the oncomplete event of the managedresourcestore, like so:

var localServer = google.gears.factory.create('beta.localserver');
var store = localServer.createManagedStore("test");

store.manifestUrl = '/test.nsf/gears_manifest.json?open';
store.onerror = function(){
        alert("There was a problem downloading "+
                "the files needed to run offline");
store.oncomplete = function(){
        var lstore;
        lstore = localServer.createStore('other');              
        function(url, success, captureId){
                if (success){
                        alert("Manifest file stored: "+url);

What it does is create two local stores of files - a managed one and an unmanaged one which contains just the manifest file.

While the manifest file does get stored locally it doesn't stop Gears trying to go online.

The next thing I tried to do was add the URL of the manifest file to the manifest itself. Talk about a hack!

The manifest file (gears_manifest.json) then looked like this:

  "betaManifestVersion": 1,
  "version": "v1.0",
        { "url": "Test", "src":"Test?Open&offline=true", "ignoreQuery":true },
        { "url": "gears_init.js" },
        { "url": "Offline.js" },
        { "url": "spinner.gif" },
        { "url": "gears_manifest.json" }

Again, this worked, in that it stored the file locally but it didn't prevent a forced attempt to connect.

Then it dawned on me how stupid I was being:

It seems that, as Gears is making the request, rather than intercepting it, it doesn't ever check for the manifest file in the ResourceStore. It just sends the request straight to the internet.

Which makes sense I guess? Why would it look in its own store first? Doh!

No Solution

So, alas, there's no answer to this problem as far as I can tell. Even though I'm not the only one who wants this feature.

It's a shame that Gears is lacking in this one area, as, apart from the annoyance of having these "can't connect" message I've found Gears to be a brilliant product so far. It's done everything I've asked of it.

I guess it is only a "beta" still (version 0.5.23 as of writing this) so maybe we shouldn't expect a highly polished product yet and the feature I'm requesting will arrive one day.


    • avatar
    • Richard C
    • Tue 7 Jul 2009 07:27 AM

    Regarding the "?" in the url, if you configured/coded your Lotus Domino application to use "!" instead, would that help you in any way?

    • avatar
    • Jake Howlett
    • Tue 7 Jul 2009 07:54 AM

    Unfortunately not Richard. Not that I'd implement that server-wide change anyway.

    Never liked the idea of messing with the fundamental concept of a URL just so Domino can pretend to Google that it really is indexable.

    • avatar
    • Aaron Hardin
    • Tue 7 Jul 2009 08:22 AM

    Sorry, but I haven't heard of modifying a url with an exclamation mark before. Don't suppose you could elaborate on it could you?

    • avatar
    • Jake Howlett
    • Tue 7 Jul 2009 08:26 AM

    No Aaron. Pretend you never heard of it. It's a pointless exercise in which Domino tries to fool search engines in to thinking it's not "CGI-based" and is ok to be indexed. It was only of any use in about 1998.

    • avatar
    • dpk
    • Thu 8 Oct 2009 07:04 AM

    Thanks for the posting above comments,

    thats exactly what i am facing, no such handle in gears which prevent a forced attempt to connect, but overall functionalities of gears are good.

    Even you remove browser cache, the local store is available to server the application, I really liked the gears.

    although some missing features are;

    1. The one for this post

    2. Gears doesn't working with Windows Mobile 6.5

    Have you faced anything related to caching for gears + windows mobile + MSIE6 + xmlHTTPRequest ?

Your Comments


About This Page

Written by Jake Howlett on Tue 7 Jul 2009

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content