<分区>
我想设置一个过期时间,以检查文件或图像是否已被修改。请注意,图像是从 SQL Server 数据库中检索的。
我也更喜欢在 IIS 上而不是在 Handler 文件中的 C# 代码上进行缓存。
我还没有想出任何东西。
谢谢。
<分区>
我想设置一个过期时间,以检查文件或图像是否已被修改。请注意,图像是从 SQL Server 数据库中检索的。
我也更喜欢在 IIS 上而不是在 Handler 文件中的 C# 代码上进行缓存。
我还没有想出任何东西。
谢谢。
最佳答案
假设您的根文件夹中有一个名为 Handler.ashx 的 http 处理程序,对 web.config 的以下更改将指示 IIS 将输出缓存 1 天:
<location path="Handler.ashx">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="max-age" value="86400"></add>
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
您还可以设置过期 header 。 http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/
关于c# - 如何缓存处理程序文件和图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25394887/