views:

208

answers:

2

I have a program that checks if a file is present every 3 seconds, using webrequest and webresponse. If that file is present it does something if not, ect, that part works fine. I have a web page that controls the program by creating the file with a message and other variables as entered into the page, and then creates it and shoots it over to the folder that the program is checking. There is also a "stop" button that deletes that file.

This works well except that after one message is launched and then deleted, when it is launched the second time with a different message the program still sees the old message. I watch the file be deleted in IIS, so that is not the issue.

I've thought about meta tags to prevent caching, but would having the file be dynamically named solve this issue also? How would I make the program be able to check for a file where only the first part of the filename is known? I've found solutions for checking directories on local machines, but that won't work here.

Any ideas welcome, thanks.

A: 

I'm not that used to IIS, but in Apache you can create a .htaccess and set/modify HTTP-Headers.

With 'Cache-Control' you can tell a proxy/browser not to cache a file. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

A solution like this may work in IIS too if it is really a cache problem.

(To test this, open using your preffered browser with caching turned off

cimnine
A: 

A simple hack is to add something unique to the url each time

http://www.yourdomain.com/yourpage.aspx?random=123489797

Adding a random number to the URL forces it to be fresh. Even if you don't use the querystring param, IIS doesnt know that, so executes the page again anyways.

Neil N
is this technique to invalidate output cache?
Neil
It works to invalidate both the servers output cache as well as the users browser cache, if a browser is being used.
Neil N