title: How to make your Drupal 8 response cachable by browser?
body: <p><strong>Update</strong>: Reposted on <a href="https://drupal.stackexchange.com/questions/285160/how-to-make-your-drupal-8-response-cachable-by-browser">StackExchange</a>.</p>
  
  <hr>
  
  <p>I am working on a Drupal Controller implementation that would return a generated image as response. I used Symfony's <a href="https://symfony.com/doc/current/components/http_foundation.html" rel="nofollow noreferrer">Response</a> and I was trying to add ETag header to it:</p>
  
  <pre class="lang-php prettyprint-override"><code>
  use Drupal\Core\Controller\ControllerBase;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\Response;
  
  class MyController extends ControllerBase {
  
    public static function viewGraph(string $id, Request $request) {
      $response = new Response();
      $response-&gt;setEtag($etag); // some etag genrated from $id
      if ($response-&gt;isNotModified($request)) {
        return $response;
      }
      // ...
      return $response;
    }
  
  }
  
  </code></pre>
  
  <p>I expected to see the <code>"ETag"</code> header in my response. But there is nothing. I've even tried <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Cache%21CacheableResponse.php/class/CacheableResponse/8.2.x" rel="nofollow noreferrer">CacheableResponse</a> and it didn't work as well.</p>
  
  <p>What's wrong with my approach? What is the right approach to it?</p>