gpt4 book ai didi

ASP.NET 输出缓存、varyByParam、varyByHeader 和 AJAX

转载 作者:行者123 更新时间:2023-12-02 12:19:26 25 4
gpt4 key购买 nike

我正在为所有 Umbraco v4 页面使用输出缓存,但希望避免任何 Ajax 调用使用此类缓存...

我在default.aspx中添加了这一行:

<%@OutputCache CacheProfile="umbProfil" %>

然后,在 web.config 中:

<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="umbProfil" duration="120" enabled="true" varyByHeader="???"
varyByParam="umbPage" location="ServerAndClient" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>

现在的问题是所有内容都被缓存,包括我的 Ajax 调用,实际上不应该这样:它们主要是表单,并且字段条目使用初始值维护,直到缓存过期...

让您知道,这些 Ajax 是“部分 View ”,即仅呈现某些表单的 Umbraco 常规页面...

我应该如何设置 VariableByHeader 参数,以便实际上缓存与 umbPage 相关的所有内容(Ajax GET/POST 调用除外)?

最佳答案

由于我在每个表单上使用防伪隐藏文本字段,因此我最终使用此表单参数作为变化参数。

<add name="umbProfil" duration="120" enabled="true"
varyByParam="umbPage;__RequestVerificationToken" location="ServerAndClient" />

它似乎运行良好,我的 umbPage 被缓存,而我的表单 POST 没有(或者至少为每个 POST 生成一个缓存实例,持续 120 秒)。

如果你们有更好的主意(任何帖子都没有缓存),请提出建议。

关于ASP.NET 输出缓存、varyByParam、varyByHeader 和 AJAX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11110875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com