如何设置响应头';Sitecore中的缓存控制?

如何设置响应头';Sitecore中的缓存控制?,sitecore,sitecore6,Sitecore,Sitecore6,默认情况下,Sitecore似乎不缓存页面。在web.config中,设置 <setting name="DisableBrowserCaching" value="false"/> page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); page.Response.Cache.SetCacheability(HttpCacheability.Public); 但它不工作,响应头保持无缓存。顺便说一下,我在渲染布

默认情况下,Sitecore似乎不缓存页面。在web.config中,设置

<setting name="DisableBrowserCaching" value="false"/>
page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
page.Response.Cache.SetCacheability(HttpCacheability.Public); 

但它不工作,响应头保持
无缓存
。顺便说一下,我在
渲染布局中添加了管道,有人知道吗?谢谢

我试图通过首先将
DisableBrowserCaching
设置设置为
true
来重现这一点。这确实会产生一个无缓存头

page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
page.Response.Cache.SetCacheability(HttpCacheability.Public); 
然后我将其设置为
false
并重新加载页面,无缓存头消失。没有必要再做别的了

page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
page.Response.Cache.SetCacheability(HttpCacheability.Public); 

如果要设置过期标头,应在IIS中的HTTP响应标头功能中执行此操作。

Sitecore在将内容呈现为HTML之前有7层缓存。在呈现内容之前,可以控制每个服务器上的缓存。但是,默认情况下没有缓存是正确的

page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
page.Response.Cache.SetCacheability(HttpCacheability.Public); 
这是因为Sitecore中的页面是动态的。它们会根据当前情况更改布局和内容。特别是当您使用devices()和Sitecore DMS时,每个设备和用户的内容呈现方式都不同

page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
page.Response.Cache.SetCacheability(HttpCacheability.Public); 

如果您构建自己的浏览器缓存机制,请确保仅在包含静态内容的页面上执行此操作。

您使用的是哪个版本的Sitecore?谢谢!我想出来了。layout.aspx中有一个。这就是API不起作用的原因。先把它取下来!
page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
page.Response.Cache.SetCacheability(HttpCacheability.Public);