code: func (ns *Namespace) getRemote(cache *filecache.Cache, unmarshal func([]byte) (bool, error), req *http.Request) error {
  	url := req.URL.String()
  	id := helpers.MD5String(url)
  	var handled bool
  	var retry bool
  
  	_, b, err := cache.GetOrCreateBytes(id, func() ([]byte, error) {
  		var err error
  		handled = true
  		for i := 0; i <= resRetries; i++ {
  			ns.deps.Log.INFO.Printf("Downloading: %s ...", url)
  			var res *http.Response
  			res, err = ns.client.Do(req)
  			if err != nil {
  				return nil, err
  			}
  
  			if isHTTPError(res) {
  				return nil, errors.Errorf("Failed to retrieve remote file: %s", http.StatusText(res.StatusCode))
  			}
  
  			var b []byte
  			b, err = ioutil.ReadAll(res.Body)
  
  			if err != nil {
  				return nil, err
  			}
  			res.Body.Close()
  
  			retry, err = unmarshal(b)
  
  			if err == nil {
  				// Return it so it can be cached.
  				return b, nil
  			}
  
  			if !retry {
  				return nil, err
  			}
  
  			ns.deps.Log.INFO.Printf("Cannot read remote resource %s: %s", url, err)
  			ns.deps.Log.INFO.Printf("Retry #%d for %s and sleeping for %s", i+1, url, resSleep)
  			time.Sleep(resSleep)
  		}
  
  		return nil, err
  
  	})
  
  	if !handled {
  		// This is cached content and should be correct.
  		_, err = unmarshal(b)
  	}
  
  	return err
  }
docs: // getRemote loads the content of a remote file. This method is thread safe.