Capturing cache metadata from file_create_url?
This code seems to be OK to me until file_create_url() is transformed into a service which can handle cacheable metadata like UrlGenerator.

An easier way to avoid this error message would be to return an uncacheable RedirectResponse:

  $url = file_create_url($file-&gt;getFileUri());
  $response = new RedirectResponse($url);
  return $response;