code: function ampByExampleHandler(request, values) {
    if (shouldNotCache(request)) {
      return toolbox.networkOnly(request, values);
    }
    // for samples show offline page if offline and samples are not cached
    if (requestAccepts(request, 'text/html')) {
      // never use cached version for AMP CORS requests (e.g. amp-live-list) or pages that shouldn't be cached
      if (request.url.indexOf("__amp_source_origin") != -1) {
        return toolbox.networkOnly(request, values);
      }
      // network first, we always want to get the latest
      return toolbox.networkFirst(request, values).catch(function() {
        return toolbox.cacheOnly(new Request(config.offlinePage), values)
          .then(function(response) {
            return response || new Response('You\'re offline. Sorry.', {
              status: 500,
              statusText: 'Offline Page Missing'
            });
          });
      });
    }
    // always try to load images from the cache first
    // fallback to placeholder SVG image if offline and image not available
    if (requestAccepts(request, 'image/')) {
      return toolbox.cacheFirst(request, values).catch(function() {
        const url = request.url;
        const fileName = url.substring(url.lastIndexOf('/') + 1);
        // TODO use correct image dimensions
        return new Response(offlineImage(fileName, 1080, 610), {
          headers: {
            'Content-Type': 'image/svg+xml'
          }
        });
      });
    } else {
      // cache first for all other requests
      return toolbox.cacheFirst(request, values);
    }
  }
docs: ampbyexample.com fetch handler:
  
  - one-behind caching
  - shows offline page
  - generates placeholder image for unavailable images