IIS/缓存问题?

发布于 2024-08-05 06:22:55 字数 364 浏览 3 评论 0原文

我有一个程序,使用 webrequest 和 webresponse 每 3 秒检查一次文件是否存在。如果该文件存在,它会执行某些操作,如果不存在,则该部分工作正常。我有一个网页,它通过创建带有消息和输入页面的其他变量的文件来控制程序,然后创建它并将其发送到程序正在检查的文件夹。还有一个“停止”按钮可以删除该文件。

这种方法效果很好,只是在启动一条消息然后删除后,当使用另一条消息第二次启动时,程序仍然会看到旧消息。我看到文件在 IIS 中被删除,所以这不是问题。

我考虑过使用元标记来防止缓存,但是动态命名文件是否也可以解决这个问题?如何使程序能够检查仅知道文件名第一部分的文件?我找到了检查本地计算机上目录的解决方案,但这在这里不起作用。

欢迎任何想法,谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

热情消退 2024-08-12 06:22:55

我不太习惯 IIS,但在 Apache 中,您可以创建 .htaccess 并设置/修改 HTTP 标头。

使用“缓存控制”,您可以告诉代理/浏览器不要缓存文件。
http://www.w3.org/Protocols/rfc2616/rfc2616-sec13。 。

如果确实是缓存问题,这样的解决方案也可能在 IIS 中起作用

(要测试这一点,请使用您首选的浏览器打开并关闭缓存

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

中二柚 2024-08-12 06:22:55

时向网址添加一些唯一的内容

一个简单的技巧是每次http://www.yourdomain .com/yourpage.aspx?random=123489797

向 URL 添加随机数会强制其保持最新状态。即使您不使用查询字符串参数,IIS 也不知道这一点,因此无论如何都会再次执行该页面。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文