FileDownloader: Switch off browser caching

I’m using the Vaadin FileDownloader.

When clicking on the corresponding button for the first time, Firefox caches the downloaded file. If I’m not refreshing the screen, the second time the browser doesn’t contact FileDownloader anymore but immediately offers the cached file.

The files I’m downloading are dynamically generated before download - so I need an option to switch off this browser behaviour.

I’ve found this link: [https://stackoverflow.com/questions/12331993/how-to-disable-browser-caching-in-vaadin?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa]
(https://stackoverflow.com/questions/12331993/how-to-disable-browser-caching-in-vaadin?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) …

… but how can I do this with FileDownloader?

Hi,
I have solve this problem by changing filename every time it is downloaded (add timestamp). I know this is not solution for every case…
Regards,
Matic

Hi Matic, yes this is right - I’m doing the same - I do it exactly like in the example under “LAZILY DETERMINE THE CONTENT AND THE NAME OF THE FILE BEING SERVER” on [https://vaadin.com/docs/v8/framework/articles/LettingTheUserDownloadAFile.html]
(https://vaadin.com/docs/v8/framework/articles/LettingTheUserDownloadAFile.html).
But when I’m in my Firefox and click the second time (see description above), the overriden method handleConnectorRequest isn’t any more called and therefore there is no chance to change the filename. Therefore I assume, that it has to do something with caching. But how to force the browser not to cache in this case?

Hi Mirko,
I have the same issue. (Only in Firefox)
When I am downloading the second time, I am getting the previously cached file as well.
When I cleared the cache and tried again, it works fine.

Have you found a solution?

Thanks
Jamshid

No, unfortunately not. I’ve raised an issue in github now:

https://github.com/vaadin/framework/issues/10909

Hi Mirko, Thanks for the reply. I have found a solution as posted below by overriding the handleConnectorRequest method of FileDownloader to disable the cache during file download.

https://stackoverflow.com/questions/12331993/how-to-disable-browser-caching-in-vaadin?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

Hope this is what you are looking for…

Hi Jamshid, thank you! Yes - and I’ve got a similar response on github. Look here: [https://github.com/vaadin/framework/issues/10909]
(https://github.com/vaadin/framework/issues/10909). That solves this problem!