code: func (ih *ImageHandler) cached(ctx context.Context, br blob.Ref) (io.ReadCloser, error) {
  	rsc, _, err := ih.Cache.Fetch(ctx, br)
  	if err != nil {
  		return nil, err
  	}
  	slurp, err := ioutil.ReadAll(rsc)
  	rsc.Close()
  	if err != nil {
  		return nil, err
  	}
  	// In the common case, when the scaled image itself is less than 16 MB, it's
  	// all together in one blob.
  	if strings.HasPrefix(magic.MIMEType(slurp), "image/") {
  		thumbCacheHitFull.Add(1)
  		if imageDebug {
  			log.Printf("Image Cache: hit: %v\n", br)
  		}
  		return ioutil.NopCloser(bytes.NewReader(slurp)), nil
  	}
  
  	// For large scaled images, the cached blob is a file schema blob referencing
  	// the sub-chunks.
  	fileBlob, err := schema.BlobFromReader(br, bytes.NewReader(slurp))
  	if err != nil {
  		log.Printf("Failed to parse non-image thumbnail cache blob %v: %v", br, err)
  		return nil, err
  	}
  	fr, err := fileBlob.NewFileReader(ih.Cache)
  	if err != nil {
  		log.Printf("cached(%v) NewFileReader = %v", br, err)
  		return nil, err
  	}
  	thumbCacheHitFile.Add(1)
  	if imageDebug {
  		log.Printf("Image Cache: fileref hit: %v\n", br)
  	}
  	return fr, nil
  }
docs: // cached returns a FileReader for the given blobref, which may
  // point to either a blob representing the entire thumbnail (max
  // 16MB) or a file schema blob.
  //
  // The ReadCloser should be closed when done reading.