Stop cache of downloaded file

Hi,

Is there a way to stop the browser caching a downloaded file.

The file is a .xls (Excel) file and is updated regularly during the session. It's part of an ASP application and the user gets a distinct file name for the session.

The problem is that when the user clicks on the link the browser doesn't download the file, it just gets it from cache.

The link looks like this:
<a TITLE="Show results in Excel" HREF="<%=Session("UserFile")%>"><img SRC="../images/toexcel.gif" HEGHT="35" WIDTH="36" BORDER="1"></a>

Session("UserFile") = ../Excel/WD245365367.xls
the number is the Session.SessionId value.

I've tried using:
<meta http-equiv=pragma content=no-cache>
on the page that contains the link but that only stops the page from caching not the file.

I need to use the same filename all the time because when the session ends I want to delete it, otherwise the files would build up on the server.

Any tips?

/DH
doghundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

binkzzCommented:
If this is done internally, you might want to get the user to disable the caching client-side.
0
doghundAuthor Commented:
Thanks binkzz,

Asking the user to disable caching would solve the problem but it makes the application clumsy and unfriendly.
Not to mention that some users might not know how to change their browser settings (even with instructions they mightn't dare).
I have a backup plan invisible to the user just a little bit of extra code.

I can keep a count of the files the user asks for and each file can be called <Sessionid> & <count> & ".xls"
Then in the Session_onEnd I can loop through 1 to count and delete the files.
Messy, but it'll work.

Im going to have to implement this on Monday so if I can't find a better way it'll be 'Plan B' for me.
0
binkzzCommented:
If you're feeling adventurous, you could even modify the script by adding a subroutine that will output the file to the browser in uuencoding.

This way, it will get it from the script, which means it's never going be cached and you can have the filename set to whatever you want.

Another option would be that you would keep the filename of the excel file the same, but zip it up under a different (unique) filename.

Mcbee
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

doghundAuthor Commented:
The first idea sounds good because the user sees it straight away. Sending a zip file means extra work for him/her. Plus I'd still have to get rid of the zip files from the server.

I don't know anything about uuencoding.
Does it work on Explorer and Netscape?
Can the user save the file directly in the .xls format?
Can it be opened in a new sepatrate browser window?

If the answer to all 3 questions is YES, where can I find out more about it (quick 'n easy web tutorials etc.)?
0
binkzzCommented:
The first is also the best idea, but a lot harder to execute. You will find an ASP component on http://asp.superexpert.com/softwarelist/16.html that will allow you to uuencode and uudecode files.

Uuencoding is a reasonably old protocol, and will go back to the version 3 browsers as well, so you won't need to worry about compatibility issues.

If you do it this way, you can save the file directly in the .xls format, and you can have it so that it opens in a different browser, if you wanted to. You shouldn't need to do that, because what basically happens is that when they click on the page, the download commences. As far as I can remember, the page and it contents aren't interrupted by the download.

But if you want it in a seperate browser window, you can have it in a seperate browser window ;)

Mcbee

0
doghundAuthor Commented:
Sounds perfect.

Thanks for your time.
Just lock the question and the points are yours

/DH
0
binkzzCommented:
Thank you very kindly ;)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.