Hi Phil, very cool idea to offline enable your wiki.
Gears is designed for the server to send all pages in the manifest
each time. For each URL in the manifest, it issues an HTTP conditional
GET. Only the changed pages will be downloaded.
So long as the server supports if-modified-since (which I assume
MediaWiki does), updates should be much faster than the first capture.
- a
Yes, it does, but that won't help here I don't think. The crux of the
problem is that everytime any page on the wiki has changed the entire
wiki has to be recaptured because the server updates the last update
time across the board.
One way to solve this (I suppose the way that this API was meant to be
used) is to separate the truly static resources (images, css HTML
templates, etc) from the data (the contents of the wiki pages). This
is obviously a major refactor of MediaWiki itself, and probably not a
useful answer to Phil.
Longer term, I think one interesting thing to consider for
LocalServer2 is some functionality like what Phil is describing that
would make LS more useful to multi-page sites. Basically: allow a
server to return just the changed pages since a given version. Perhaps
this could be something that could be done programattically: that way
you could call it after pressing the edit button and wait for it to
complete. It is sort of like a very basic sync protocol for static
resources.
There might be something that could be done today using ResourceStore
and hand-rolling this protocol using PHP on the server and
XHR+ResourceStore on the client. This would have the downside that
pages captured using ResourceStore do not automatically get updated,
so if there was an error, that page could get wedged,. But since the
complexity of JS on mediawiki is pretty low, I think this is less of a
risk. Also, you could have a ManagedResourceStore too that just
contains the homepage. That way, if a user ever got wedged, a request
for the homepage would unwedge you.
Does this seem like something that would work, Phil?
Interesting use case. To be honest, we designed Gears more for the
single-page style AJAX applications, where there are only a few HTML
files and the content is generated by JS. But I think your use case is
important too, and you shouldn't have to dramatically redesign things
like MediaWiki to do things like this.
We'll keep it in mind for the next version of LocalServer and
propagate this to the discussions in WhatWG for offline support in
browsers.
- a
If a server modifies a file's lastmod even if the file is not changed,
then I think it's broken. I'm not sure we should spend a ton of
effort working around this, because this kind of thing can be broken
in many different ways. [That said, I can completely understand _why_
things work this way, it is generally easier to just touch everything
than to find the minimal set of things that changed.]
Does Gears support ETag? Of course, it might suffer from the same problems :-).
I think adding a way for the server to return just the modified pages
is merely moving the problem around, because you'll have to teach the
server to do this. I suspect it wouldn't be less complicated than
teaching the server to use Last-Modified or ETag correctly!
IMHO, I'm not sure that a manifest is really the right way to offline
a wiki. To me, a wiki seems like a core set of shared resources which
could be in a ManagedResourceStore, plus a bunch of individual pages
which are managed using a ResourceStore. Then your current manifest
of changes becomes a JavaScript file which edits the appropriate
ResourceStore.
-scott