MIT license


The MIT license is an
open-source license.
$14.99 Read License

14 Day money-back guarantee

Full refund within 14 days of purchase date.

You need to log-in or create an account
  • Create an account
  • Log-in

Please use your real name.

Activation link will be sent to this address.

Minimum 8 characters

Enter your password again

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

mediaCache

mediaCache
Developed by Louis-Rémi Babé, Released Nov 26, 2011

mediaCache lets you put image, audio and video resources in a dynamic cache for offline use.

JavaScript

Tags: appcache , dynamic , mc2011 , mobile

You can now build a Twitter or Google Maps client using Open Web technologies only (read why this was impossible before).

// The exact same uri has to be used to "cache()", "remove()" it or "get()" a media to/from the cache.
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 );
});
Back to top

Additional info

How Does That Work?

mediaCache is the combination of a server-side script (currently available in php) and a JS librarys:

  • The server-side script generates iframes and unique cache manifest for each resource request, so that every resource resides in its own cache group and can be cached/removed at will.
  • The JS library knows how to send requests to the server-side script.

What Are The Limitations?

  • Obviously the browser needs to be compatible with Appcache.
  • Your website and the server-side script need to reside on the same origin (e.g. http://subdomain.domain.tld), medias can be hosted anywhere (Yay!).
  • 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).

User Reviews

No reviews have been submitted yet.

Questions & Comments


Or enter your name and Email
No comments have been posted yet.
You must be logged-in to vote. Log-in to your account or register now.