function trimCache( cacheName, max ) {
    caches.open(cacheName)
      .then( cache => {
        cache.keys()
          .then(keys => {
            if ( keys.length > max  ){
              cache.delete(keys[0])
                .then(trimCache(cacheName, max));
            }
          });
      });
  }
// limit the items in a particular cache
limit the items in a particular cache
limit the items in a particular cache
function trimCache( cacheName, max ) {
    caches.open(cacheName)
      .then( cache => {
        cache.keys()
          .then(keys => {
            if ( keys.length > max  ){
              cache.delete(keys[0])
                .then(trimCache(cacheName, max));
            }
          });
      });
  }
function trimCache ( cacheName , max ) { caches . open ( cacheName ) . then ( cache => { cache . keys ( ) . then ( keys => { if ( keys . length > max ) { cache . delete ( keys [ 0 ] ) . then ( trimCache ( cacheName , max ) ) ; } } ) ; } ) ; }
limit the items in a particular cache
limit the items in a particular cache