SSL 的 Sitecore 缓存 +非 SSL 子布局
我在子布局输出数据方面遇到了一些问题,这些数据在 SSL 和非 SSL 请求之间应该有所不同。
如果您创建子布局并在代码后面渲染出 URL,则可以进行复制。如果您随后通过 sitecore 界面将此子布局添加到页面,例如:presentation>details 等,并设置缓存并将所有缓存变量设置为打开。您是否发布等,以便页面现在可见(如果您直接通过代码中的子布局控件调用控件,则行为也相同)。
如果您以非 ssl 模式 (http://URL) 执行此页面,您将获得如下 URL: http://URL... 然后,如果您以 ssl 模式 (https://URL) 执行此页面,您的输出仍将是 http://URL...
那么有谁知道有什么方法可以得到这个,以便我们缓存两个实例。
问候, 克里斯
I have a little issue with a sublayout outputting data which should differ between SSL and non-SSL requests.
To replicate if you create a sublayout and in code behind render out the URL. If you then add this sublayout to a page through the sitecore interface, eg: presentation>details etc and set caching on and set all caching variable to on. Do you publish etc so the page is now viewable (also behaves the same if your doing it directly calling the the control by sublayout control in code).
If you execute this page in non-ssl mode (http://URL) you will get a URL such as; http://URL...
Then if you execute this page in ssl mode (https://URL) your output will still be http://URL...
So does anyone know of a way to get this so we an cache both instances.
Regards,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用现有的 VaryByParm 功能,通过以编程方式设置具有完整请求 URL(包括方案)的子布局的缓存键来创建 VaryByUrl 行为。我相信这与 Mark Ursino 的回复中描述的过程相同:在 Sitecore 中自定义子布局缓存< /a>
作为旁注,如果在具有语言前缀的多语言网站中,请注意使用 Sitecore.Context.RawUrl 将为您提供带有语言前缀 的请求 URL由 StripLanguage preProcessRequest 管道步骤的操作输出。
保罗
You can use the existing VaryByParm functionality to create a VaryByUrl behaviour by programatically setting the cache key for the sublayout with the complete request url, including the scheme. I believe this would be the same process as described in Mark Ursino's response here: Customizing sublayout caching in Sitecore
As a side note, if in a multilanguage site with language prefixes be aware that using Sitecore.Context.RawUrl will give you the request url with language prefixes stripped out by the actions of the StripLanguage preProcessRequest pipeline step.
Paul
我想我看到了您的问题——您正在输出图像的绝对 URL,并且根据第一个请求是否使用 SSL,图像的 SSL URL 可能会也可能不会包含在缓存的输出中。
我的第一个建议是如果可能的话禁用绝对 URL。您有需要它们的理由吗?
我的备份是指向 Web.config 中的 renderControls 配置。如果我们在这里讨论子布局,您可能会子类化子布局,并为子布局渲染创建一个新工厂。当您子类化 sublayout 时,重写其 GetCacheKey 方法以添加标志(如果请求是 ssl...
//if request is ssl)
返回base.GetCacheKey()+"#ssl";
公平警告,我从未这样做过,只是根据可用的 Sitecore 配置和 API 提出了有根据的建议。
祝你好运。
I think I see your issue -- you are outputting absolute URLs for your images, and based on whether or not SSL is used on the first request, the SSL URL of your images may or may not be included in the cached output.
My first suggestion is to disable absolute URLs, if possible. Is there a reason you need them?
My backup would be to point you at the renderingControls configuration in Web.config. If we're talking about sublayouts here, you could potentially subclass sublayout, and create a new factory for sublayout rendering. When you subclass sublayout, override its GetCacheKey method to add a flag if the request is ssl...
//if request is ssl
return base.GetCacheKey()+"#ssl";
Fair warning that I've never done this, just making an educated suggestion based on available Sitecore config and APIs.
Good luck.