0
votes

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

2
You say each should be different. What EXACTLY should be different between the SSL and non-SLL versions? Explain what the difference is and where that difference is controlled (code, sitecore content, etc). - Mark Ursino
hey Mark, Sitecore should be controlling the difference, if you enable full urls on it's media (set in web.config in LinkManager section) the system will cache the first instance that being ssl or non-ssl. From what i can tell they also need a VarByPrefix option. - CGiddings
I still don't understand. What specifically should be different between the two versions? Give me an example. Is the sublayout using a datasource or reading from the context item? Or even reading from another specific item? If so then you can cache and Vary by Data. - Mark Ursino

2 Answers

1
votes

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

0
votes

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.