views:

27

answers:

2

I have MVC 2 site, and I.E is cacheing word documents linked on my site. I know there is a way to clear cache before every action in the controller. But for these links i am not using action, i am just creating regular href links.. Is there anyway i can clear the cache?

A: 

I don't think you can remove cached contents from browser. But you can make future requests not to store them in cache. Assuming the docs are hosted on IIS. Take a look at this link here to set the content expires response header so the content expires immediately or expire in the past. What it does is to tell browsers / proxy servers not to cache the content because it is expired.

airmanx86
+1  A: 

Another, slightly clumsier solution, if you have control over the links / if they are dynamic at all, you can append a unique querystring to the end of the url to the document. The unique querystring causes the link to be interpreted as a new resource by the browser, so it will always download it.

A little more slick is to append something like the modified date of the file in the querystring. Then the document can remain cached until it changes, when the link will change.

The querystring should never affect how the link actually gets treated, it will simply link to the resource.

CodeBadger
pefect this worked.
WingMan20-10