Skip to content

Instantly share code, notes, and snippets.

@aarongustafson
Created September 14, 2016 20:12
Show Gist options
  • Save aarongustafson/2a956917390cbfa915a344ab41becbaa to your computer and use it in GitHub Desktop.
Save aarongustafson/2a956917390cbfa915a344ab41becbaa to your computer and use it in GitHub Desktop.
// Caching fallback from ServiceWorker to sessionStorage
function setCacheItem(){}
function getCacheItem(){ return undefined; }
if ( ! ( 'serviceWorker' in window.navigator ) )
{
var cache = window.sessionStorage;
setCacheItem = function( key, text ) {
return cache.setItem( key, text );
};
getCacheItem = function( key ) {
return cache.getItem( key );
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment