Browser always download old version of file RRS feed

  • Question

  • User1487175000 posted


    In my web application i am creating a word file form template file and save at server. 

    when user click at download button i create word file with dynamic content and save at specific path at server.

    File name is constant e.g "DOC.docs". 

    Now content is change and user click download button again then my code generate file with same name "DOC.docs" and save into it.

    But once document is download at user end user get the old file. Eventhough my code update the file with new content.

    So i was thinking my webserver hold the file in cach and return the old file because file name is exactly same.

    Any idea how to solve?

    Monday, September 16, 2019 2:51 PM


  • User-821857111 posted

    Most likely the browser is caching the file. You can stop this happening by setting Response.Cache.SetCacheability(HttpCacheability.NoCache); in the handler that manages your file download.

    If you aren't using a generic handler to serve the file, you should do.


    Alternatively, append a random query string value to the download link. How you do this depends on the version of ASP.NET that you are using. You can use Guid.NewGuid to generate the value:

    var link = "/docs.doc?_=" + Guid.NewGuid();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 16, 2019 3:35 PM