views:

63

answers:

2

This may be some "best practices" thing I've overlooked or don't know about, so go easy on me please.

I have an asp.net website that populates a gridview with columns from my database table. One of those columns gets processed into a link to a word document on another server. The issue is that if a user clicks on the word document to view it, and then that document is updated on the remote server, the user cannot access the changed document until their browser cache is cleared and it's forced to go out to the network to grab a fresh copy when the link is clicked.

Basically I want to somehow force the machine never to use the cached copy of the document, but always go out to the network to get the newest copy.

Bonus question: Would this be better handled somehow by storing the documents in SharePoint?

UPDATE: using Response.Cache.SetCacheability(HttpCacheability.NoCache); in my codebehind I have now resolved the issue in FireFox, but IE8 is weird. If I update the document and then left click on it, it brings up the word doc in the IE window without the changes. However, if I make changes, save them and then middle click on the document so it opens up a new tab, the document reflects the changes. I'm mostly there...

+1  A: 

By chance are you seeing this with IE8 specifically? We've seen it show this behavior where caching was previously not an issue.

Typically it can be cleared up with a couple steps: explicitly telling the browser not to cache via HTTP headers, and also expiring the page immediately. Google the "pragma no-cache" header, there is typically a couple of different lines you need to add to cover all browsers.

STW
Actually this is happening across all browsers, I just haven't really dealt with it until now. My coworker uses IE7 and my boss and I use Firefox, same issue. Thanks for the direction.
somacore
+2  A: 

Try adding a little extra data to the link. Here's an example using js; if you're building the url server side, it should be essentially the same:

var url = "http://www.mydomain.com/mywordfile.doc?ts=" + (new Date()).getTime();

That'll force the url to have a different query url each time, which (in theory) should force the browser to re-request and re-download it.

jvenema