I have an anchor tag that is used to request the download of a file.
Like this:
<a href="app/results?fileName=t12.txt&other-param=something" title="Click to download"> Download </a>
The file may be modified on the server very often, so I want to make sure the browser does not cache the file.
However, testers found out that, although it seems to always download the file when you click on the link, when you right-click on the link and choose "Save As...", the browser seems to choose to use the cached file instead. This was tested with IE9.
How can I force the browser (especially IE9) to always download the file in every case?
I'll add as an answer. Try adding a random number to the query part of the href:
?param=[random]
As per my own comment for one of the answers:
According to wikipedia I can set the response header parameter: Cache-Control: no-cache
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Effects_of_selected_HTTP_header_fields
After receiving a response with this header, the browser will not cache this data anymore.
来源:https://stackoverflow.com/questions/10274591/force-browser-to-not-use-cache-when-requested-for-file-using-anchor-tag