Search code examples
htmlasp.net-mvccachingkendo-uihref

How to make sure a resource is pulled from server, not cache?


The situation is this, I have a website that manages project outlines, users can upload PDFs to a pop up window, and then can click a link on the profile section of the project outline to see their PDFs on another pop up window.

Currently, if you upload a PDF that is replacing an old one, the browser will still show an old version of the PDF. I figured out that what is shown is a cached version of that PDF. The PDFs must maintain a consistent name (An outline of a project called X, will always be called "Outline X.pdf")

I was looking for a way to make sure that what is shown is ALWAYS pulled from the server. I don't need to pull the entire page from server, only certain resources.

Thank you for the help!


Solution

  • You can set headers as follow to prevent caching :

    Expires: 0
    Pragma: no-cache
    Cache-Control: no-cache, no-store, must-revalidate
    

    You can also append a random querystring (like timestamp) to the filename.