title: VAADIN: StreamResource with duplicate fileName uses old StreamResource
body: <p>I have a view, in I have two buttons. One for creating a PDF file and another one to preview the generated PDF file.</p>
  
  <p>The method to create the file returns a <code>ByteArrayOutputStream</code>, which I then save as a <code>byte[]</code> as a field of the view.</p>
  
  <p>The method to preview the generated file then takes this <code>byte[]</code> and shows it like this:</p>
  
  <pre><code>private void viewPDF() {
  
      final ByteArrayInputStream data = new ByteArrayInputStream(this.cancellationByteArray);
  
      final Window window = new Window();
      window.setHeight("95%");
      window.setWidth("95%");
  
      final StreamSource source = () -&gt; data;
  
      final String fileName = "Cancellation";
  
      final StreamResource resource = new StreamResource(source, fileName);
      resource.setMIMEType("application/pdf");
  
      final BrowserFrame browserFrame = new BrowserFrame(null, resource);
      browserFrame.setWidth("100%");
      browserFrame.setHeight("100%");
      window.setContent(browserFrame);
      window.center();
      UI.getCurrent().addWindow(window);
  }
  </code></pre>
  
  <p>With this I noticed something strange. When I generated a PDF and previewed it, everything was fine. However, when I restarted the application, generated a new one and previewed it again, I would always first see the old PDF, which I generated first. Clicking the preview button again would then show the one I just generated. If I then generate a new PDF again and click preview, it shows the correct one again. So from this point the application basically works as expected.</p>
  
  <p>Now, I found that making the <code>fileName</code> parameter of the <code>StreamResource</code> dynamic resolved that error. If I for example generate the name like this:</p>
  
  <pre><code>final String fileName = "Cancellation-" + this.DATE_FORMAT.format(new Date());
  </code></pre>
  
  <p>Then it would always show the newest version. </p>
  
  <p>So why does it work like this? Does the browser cache the <code>StreamResource</code>, and on clicking the button again it looks, if it already has a <code>StreamResource</code> with the same <code>fileName</code>? However that would, in my opinion not explain why my workaround of cycling through the old PDFs works.</p>