开发者

Sitecore Caching for SSL + non-SSL sublayout

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜