|
3#
楼主 |
发表于 4-6-2008 21:53:27
|
只看该作者
The next-gen web is starting to gather pace, as this week MySpace integrated Google Gears, Yahoo! announced their new BrowserPlus product and Google launched a browser-based edition of their 3D Earth product. Technologies and formats such as AIR, Silverlight, JavaFX, Gears, XUL, Web Applications 1.0(DOM5, HTML5 etc.) allow developers to accelerate beyond AJAX andtowards a new generation of web applications with better performance,more functionality and tighter desktop integration.
Developersand users are now presented with more web technology choice then everbefore; “DLL hell” has been superseded by “plug-in hell”, as a varietyof companies present their versions of what the next-gen web will looklike. But on the web, such choice can come at a cost to both users anddevelopers. More than a decade has passed since the first battle overweb formats, back then it was Microsoft, Netscape, Apple, AOL andothers laying different foundations in the form of browsers, scriptinglanguages, web servers and more. The legacy of that battle is stillbeing felt today, as Javascript developers rely on whole libraries to assist them in developing cross-browser code and CSS developers depend on a catalog of hacks so that their sites can look consistent across different browsers.Withthe new rich web application technologies still in the developmentphase, there is an opportunity to not repeat the mistakes of the pastand instead take a standards-based approach. Thankfully during thecourse of the previous decade companies such as Microsoft became morereceptive to open standards, data portability and cross-platformsupport. Having broad support for open standards simplifies technologyfor both users and developers, but it is obvious that not all of thecurrently announced technologies, such as those listed above, will
Browser-based Local Storage
Asweb applications became more popular there was a general demand for anability to run web-based applications offline. The first such solutionsthat could work without requiring a browser plugin or separateapplication were those that relied on the caching headers within HTTPto store objects within the browsers cache. Javascript libraries suchas Dojo implemented support for offline web applicationsusing the same principals, but applications were very limited in scopeas there was no easy way to store structured data on the browser (Dojonow also abstracts a variety of other storage engines including Gears - tip: Dylan) .
In May of 2007, Google launched Google Gears,a browser plugin that allows web applications to synchronize data intoa local data store and then allow web applications to function offline.At the launch of Gears, Google Reader was adapted to support it, andthe emphasis of the pitch for Gears was about offline applicationaccess. What was less known is that Gears is a lot more than justoffline access, as it provides three primary functions:
- Caching of resources (HTML pages, images etc.)
- Structured data storage in a database
- Asynchronous background worker threads
Thepart of this we will focus on here is the local object and structureddata storage. Gears provides these functions via a Javascript API,which can be accessed by any web application. The structured storage isprovided by Sqlite,a popular lightweight RDBMS. With the local database, the developer cannot only perform queries and inserts to record new data, but also morecomplex SQL like joining between tables etc. Although you can havemultiple applications using Gears, each app runs in a sanboxedenvironment with a domain-based security model (similar to cookies andAjax requests). Sqlite has been built into Firefox since version 2.0,but its API is only accessible from an add-on or a core Firefoxcomponent. The Gears plugin bridges that gap and makes it availablewithin the client scripting environment.
Before Gears was launched, the Web Hypertext Application Technology Workgroup(WHATWG) had begun work on its Web Applications 1.0 draft spec, whichincluded structured data storage as part of HTML5. The current draftspec from the working group includes definitions for a Database objectfor accessing and querying a local data store. The details of theimplementation are left up to the vendor, but the API is detailed inthe spec. Firefox will be implementing parts of the same storage APIfrom the WHATW spec in version 3.0 of the browser, which is currently available as a preview release. The key components of the WHATWG spec are:- ApplicationCache - for storing objects in the local browser cache (and checking them)
- navigator.onLine - check if the browser is online or not (and use cache plus local data store if required)
- Storage interface and events - used for storing name and value pairs via the sessionStorage DOM attribute.
- Database interface- used for connecting to the local database. Supports SQL (or a subsetthereof, depending on the server used), versioning, error events viacallback
- Threading and Callbacks - so that multiple requests can be sent to the local data store asynchronously.
Implementinglocal storage, caching and offline access are relatively easy. Theapplication can first check to see if these functions are supported,and then setup the local cache by synchronizing the users data inbackground processes. While a thread is running, either uploading ordownloading, you can query it to check on its status to provide theuser with feedback (eg. a progress bar). Once the data is local, byrunning database queries on the local machine developers are able to drasticallyimprove performance. Currently many web applications use the browser asonly a presentation layer, for eg. a spreadsheet application may do around-trip back to the server to work out even elementary calculationssuch as =1+1. By utilizing the local data store andclient-side code, the developer is able to offload processing andstorage to the client and provide a much smoother, desktop-likeexperience at the same time.
Current And Future Support
Theissue is that the majority of the WHATW specification was written afterGears was released, so the Database and LocalServer objects used inGears are not compatible with WHATW - for now. The good news is thatGoogle have come out and fully backed the storage portionsof the WHATWG HTML5 spec, so developers with apps running on Firefox 3with Gears installed will have a choice to use either the nativeimplementation, or the Google implementation. Google go on to say thatthey will likely offer extra features as an incentive for developers tocontinue to target Gears over-and-above the HTML5 implementation(features such as desktop shortcuts, etc.).
Other alternativesfor local data storage, such as Flash local storage, are completelyincompatible with the WHATW specification. The developers at WebKit were very quick to announcethat they have started implementing the storage portions of the HTML5spec also. It is currently available in nightly builds, so in the nearfuture we will see support in both Konquror and Safari. Opera have alsoannounced similar plans and they are actually leading everybody when itcomes to implementing HTML5 and Web Forms. Yahoo! BrowserPlus was onlyannounced yesterday, and it is currently unclear wether their localstorage support is compatible with the specification as laid out by theworking group.
Local storage is a major new feature of the newweb API, and developers will not only have consistent support acrossbrowsers but will also have the option of Google Gears (which isalready available) as well as Yahoo! BrowserPlus (depending on how itworks). There is just one browser maker missing in this discussion sofar and that is Microsoft. Microsoft have released an early preview ofIE8 and announced a raft of new features, a lot of which are based onopen standards such as better CSS and Javascript support (with a morestandardized object model). The big question is wether we will seeconsistent local storage support from IE8 following the same spec asthe other browser vendors. The IE team have announced that IE8 will support DOM Storage, but that is only part of the overall local storage spec (ie the Storage object described above only).
[ 本帖最后由 coredump 于 4-6-2008 20:54 编辑 ] |
|