Note: If you have returned a render array or an HtmlResponse or a CacheableJsonResponse or a CacheableResponse or any other response implementing CacheableResponseInterface from your controller then you don't need to make any changes here.
Before 8.0.0-RC1 all directly returned Responses that have not changed max-age or other values have been cached by Drupal's caching layer in FinishResponseSubscriber.
Now - in case you return a Response from your controller that does not implement CacheableResponseInterface and want that cached - you will need to set cacheability http headers yourself.
Before:
return new Response("Hello World", 200);
would have been cached.
After:
return new Response("Hello World", 200);
is not cached as that is the Symfony default.
But:
$response = new Response("Hello World", 200);
$response->header->set('Cache-Control', 'public, max-age=600');
would be cached for 10 min before or after.
However the recommended way to for example return the ID of a node:
$response = new \Drupal\Core\Cache\CacheableResponse($node->id(), 200);
$response->addCacheableDependency($node);
Then Drupals cache tags, cache contexts and max-age will be supported.
If you use a render array and you only want to return the rendered output, then you want to use:
$build = [...];
$markup = $this->renderer->renderRoot($build);
$response = new \Drupal\Core\Cache\CacheableResponse($markup, 200);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($build));