It seems to me that you want to disable caching when downloading a PDF file. Assuming you are using a DownloadStream
to stream the content, then setting the Content-Disposition
and Cache-Control
headers as follows should work.
DownloadStream stream = new DownloadStream(getStreamSource().getStream(), contentType, filename);
stream.setParameter("Content-Disposition", "attachment;filename=" + filename);
// This magic incantation should prevent anyone from caching the data
stream.setParameter("Cache-Control", "private,no-cache,no-store");
// In theory <=0 disables caching. In practice Chrome, Safari (and, apparently, IE) all ignore <=0. Set to 1s
stream.setCacheTime(1000);
If you want to disable caching for all Vaadin requests, you'll have to look at the source of AbstractApplicationServlet, and extend methods such as #serveStaticResourcesInVAADIN
and others - this is quick tricky, as alot of them are private methods.
A simpler method may be to use an Http Servlet Filter to add the appropriate parameters to the response, without having to modify your app at all. You can write this yourself - should be quick easy - although a quick search finds the Apache2 licensed Cache-Filter : http://code.google.com/p/cache-filter/wiki/NoCacheFilter
I have not used Cache-Filter, but a quick skim suggests it'll work just fine for you.