我们的网站刚刚从 .NET 1.1 迁移到 .NET 3.5,并在此过程中更新了我们的第 3 方服务器控件。 这些包之一使用通过 WebResource.axd 提供的 javascript。 这些内容作为正常的
然而,通过观察流量,我发现这些 javascript 文件遇到了阻止客户端缓存的标头。 我们谈论了很多 JavaScript。 有问题的标头:
Cache-control: no-cache, no-store
pragma: no-cache
Expires: -1
这些标头可以在 .NET 中的某个位置进行配置吗? 我可以在构建 HttpModule 的情况下拦截这些请求吗? 这是我可以责怪控制供应商的事情吗? >
谢谢,
男爵
Our site just moved from .NET 1.1 to .NET 3.5, and in the process updated our 3rd party server controls. One of these packages uses javascript provided via WebResource.axd. These are included as normal <script src="" /
> tags.
Watching the traffic, however, I see that these javascript files are coming across with headers that prevent client-side caching. And we're talking a lot of javascript. The headers in question:
Cache-control: no-cache, no-store
pragma: no-cache
Expires: -1
Are these headers configurable in .NET somewhere? Can I intercept these requests short of building an HttpModule? Is this something I can blame the control vendor for? <brandish weapon="blameGun" /
>
Thanks,
Baron
发布评论
评论(3)
您可以尝试:
其他类型的
HttpCacheability
记录在此处:http://msdn.microsoft.com/en-us/library/system.web.httpcacheability.aspx
编辑:
您可以将其放入
Global.asax
文件而不是模块:You could try:
The other types of
HttpCacheability
are documented here:http://msdn.microsoft.com/en-us/library/system.web.httpcacheability.aspx
Edit:
You can throw this in your
Global.asax
file instead of a module:如果您的网站部署时在其 web.config 中设置了
,则可能会发生这种情况。 在这种情况下,缓存被禁用,以便更轻松地调试用作嵌入式资源的 JavaScript 文件。 解决办法就是简单地将compilation标签的debug属性设置为false即可。 更多信息可以在这篇优秀博客文章中找到。This may occur if your web site is deployed with
<compilation debug="true">
set in its web.config. Caching is disabled in this case for easier debugging of JavaScript files served as embedded resources. The solution is to simply set the debug attribute of the compilation tag to false. More info can be found in this excellent blog post.感谢您的回复。 事实证明我们已经有了我不想写的 HttpModule,这就是问题的根源。
Thanks for your responses. It turned out we already had the HttpModule that I didn't want to write in place, and it was the source of the problem.