My question is short (and hopefully simple to solve!): How can I completely disable browser-caching in my webservice realized with vaadin?
I want to completely disable caching since I'm getting problems when I try to do some PDF streaming and displaying them in my browers.
I have read about a solution for my problem for example here:
Using <meta> tags to turn off caching in all browsers?
They talk about adding some headers to the web application that disable browser caching. But how do I add them to my Vaadin application?
A short code snippet would be very welcome (and helpful!)
Thanks once again for every answer and thought you're sharing with me.
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 theContent-Disposition
andCache-Control
headers as follows should work.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.