如何强制 ASP.NET 图表控件不被缓存

发布于 2025-01-06 05:44:54 字数 445 浏览 6 评论 0原文

有谁知道如何强制 ASP.Net Chart 控件生成的图表图像不被缓存?

我尝试将以下内容添加到母版页 Page_Load 方法中,

        Response.AddHeader("Pragma", "no-cache");
        Response.CacheControl = "no-cache";
        Response.Cache.SetAllowResponseInBrowserHistory(false);
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
        Response.Expires = -1; 

但没有任何乐趣。

有什么想法吗?

谢谢

Does anyone know how to force a chart image generated by the ASP.Net Chart control not to be cached?

I have tried adding the following to the master page Page_Load method

        Response.AddHeader("Pragma", "no-cache");
        Response.CacheControl = "no-cache";
        Response.Cache.SetAllowResponseInBrowserHistory(false);
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
        Response.Expires = -1; 

With no joy.

Any ideas?

Thanks

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

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

发布评论

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

评论(2

探春 2025-01-13 05:44:54
<add key="ChartImageHandler" value="storage=file;timeout=20;url=~/ChartImages/;deleteAfterServicing=true;" />

这会导致文件在生成后被删除。下次加载页面时,图表控件应该生成一个带有新 ID 的新图表。

我想主要问题是:您是否 100% 确定浏览器实际上正在缓存图像?

<add key="ChartImageHandler" value="storage=file;timeout=20;url=~/ChartImages/;deleteAfterServicing=true;" />

This causes the file to be deleted after generation. The next time the page is loaded the chart control ought to generate a new chart, with a new id.

I guess the main question is: are you 100% certain the browser is actually caching the image?

‖放下 2025-01-13 05:44:54

我不认为在该标记中显式设置 deleteAfterServicing 参数,因为它的默认值为 true。

I don't think to set that deleteAfterServicing parameter explicitly in that tag, because its default value is true.

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