Reputation: 1909
How to use an iframe to dynamically open multiple pdf files (one at a time according to what the client will click on) but not cache them on the client machine, because if that file content on the server got changed (added new pages to it for example), the client will still get the older version unless he/she clears the browser's cached files
Upvotes: 0
Views: 1676
Reputation: 527
Add headers in the response to avoid caching in donwstream servers
HttpContext.Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
HttpContext.Response.AppendHeader("Pragma", "no-cache");
HttpContext.Response.AppendHeader("Expires", "0");
Upvotes: 2
Reputation: 7215
You will need to disable response cacheing for the files. In the case of ASP.NET MVC, it's as simple as the following:
[OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)] // will be applied to all actions in Controller, unless those actions override with their own decoration
public class FilesController : Controller
{
public ActionResult GetFile(string id)
{
return File();//do file
}
}
Upvotes: 1
Reputation: 29801
If you suffix the url to the pdf file with a unique query string parameter, that you change whenever the pdf file is changed, the browser will cache each version of the file separately
Example:
change http://site/myFile.pdf
to http://site/myFile.pdf?v=f955b055-d551-4762-8313-a2417dc70568
Upvotes: 4