mediaCache lets you put image, audio and video resources in a dynamic cache for offline use.
You can now build a Twitter or Google Maps client using Open Web technologies only
(read why this was impossible before).
var url = "http://gravatar.com/avatar/1d924ae6b834d2c43d313a94137ac6fe&x=.png";
// add a media to the cache while online
mediaCache.cache( url, successCallback, errorCallback );
// remove a resource from the cache at anytime
mediaCache.remove( url );
// get a resource from the cache while offline
mediaCache.get( url, function( media ) {
// media is an <img>, <audio> or <video> DOM element, based on the resource extension
document.body.appendChild( media );
});
// The URI has to end with a file extension, if it's not the case, add a dummy parameter such as "x=.png" (see example above).
// Once a URI has been cached, the exact same uri has to be used to "remove()" it or "get()" it from the cache.
In Chrome: open chrome://appcache-internals/, refresh it after every cache or remove.
In Firefox: clear the browser cache (preferences > advanced), cache above resources,
switch to offline mode, and click here to .
mediaCache is the combination of a server-side script (currently available in php) and a JS library:
I'm looking for feedback regarding both the API and the logic. I'd like to encourage people to port the server-side script to their favorite language.
by @louis_remi
blog comments powered by Disqus