I have already used
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
res.setHeader("Pragma","no-cache"); //HTTP 1.0
res.setDateHeader ("Expires", 0); //prevents caching at the proxy server
but browser is still showing old cached file.

My servlet calls a procedure to generate a csv file and return the link for the same.
Now servlet gives the link to user for downloading, user clicks on link to open/save/save as the file.
If user selects open file option then first time it works ok but 2nd time onwards the browser shows the cached file instead of downloading from server.

A quick hack I've used in the past to get flash movies to not cache (don't remember why but it was important) is to add a random number as an url-parameter; that forced the browser to reload the resource on each refresh because the url was unique. You might try something similar.

A quick hack I've used in the past to get flash movies to not cache (don't remember why but it was important) is to add a random number as an url-parameter; that forced the browser to reload the resource on each refresh because the url was unique. You might try something similar.

Site works well in IE hence no other browser used.
I am giving link to a file whose content gets updated but name is constant.
So when user clicks the direct link, he gets a browser open/save/save as box.
Things work well with save as but give problem with open option.
If user clicks on open option then first time things work well but 2nd time onwards browser starts picking old cached file.

gimbal2 wrote:
yes you already said that, repeating information is not going to net you different answers.

Following statement asks me to change the URL-parameter, however in this case it is actually a direct link to a file present on server that to with a constant name.

A quick hack I've used in the past to get flash movies to not cache (don't remember why but it was important) is to add a random number as an URL-parameter; that forced the >browser to reload the resource on each refresh because the URL was unique. You might try something similar.

at this point, it sounds like you have a browser specific problem (what version of IE are you testing)? you should definitely try another browser. is the browser actually making the second request to the server? if so, the issue may not be the browser caching, so much as however the file is being saved to disk in order to load is the problem. maybe the file isn't getting overwritten properly. or maybe you aren't refreshing the program you are using to read the file (excel perhaps?).

jtahlborn wrote:
at this point, it sounds like you have a browser specific problem (what version of IE are you testing)? you should definitely try another browser. is the browser actually making the second request to the server? if so, the issue may not be the browser caching, so much as however the file is being saved to disk in order to load is the problem. maybe the file isn't getting overwritten properly. or maybe you aren't refreshing the program you are using to read the file (excel perhaps?).

Have tried with all versions of IE and it works same.
First page asks for filter criteria and on the basis the file is generated and link is given to user.
Now to get different file you have to select different criteria, based on which new file is generated.
So user has to get to first page to change criteria and get new file.
And each time I am closing the excel before reopening the new file.
Still no help.