I was working with Sitecore 6.5 when I ran into this issue with a client application.

If the Html (in a rich text field in this case) had an embedded iframe with a youtube url or a flickr slideshow, trying to perform any action on the page in page editor mode / preview mode would result in a javascript error, as in no save, no publish, nothing!

I saw the error:

Uncaught SecurityError: Blocked a frame with origin “http://mysite-local.com” from accessing a frame with origin “https://www.youtube.com“. The frame requesting access has a protocol of “http”, the frame being accessed has a protocol of “https”. Protocols must match.

This occurred even though I was accessing my site using http, and i tried accessing the youtube URL

specifically with http

without any protocol – which ideally means it should match the current browser url protocol.

But the issue persisted.

Here’s how we got around it:

The content author will need to add these potential iframe tags as anchor tags in the rich text field. These anchor tags could mandate a special attribute which would be the indicator for this custom code to trigger and transform the marked anchor tags into iframes only when the page mode is normal. (FYI, This js issue will also interfere with the ‘preview’ mode)

The content author will now enter this:

Add a processor in the <renderField> pipeline (Web.Config)

<processor type="MySite.RenderExternalLinks, MySite" />

For the condition when page mode is normal – search for all anchor tags within the rtf and if the special attribute to indicate transform is present, replace this with an iframe tag. You can you ‘data-‘ attributes to allow the content author to add additional attributes which will be applicable to the rendered iframe tag.

This post is about using ASP.Net caching with sitecore, separate from the item caching that sitecore itself provides. (Sitecore Caching)

We are all possibly aware of the way to use the cache accessible using the HttpContext.Current.Cache property. In the scenario of Sitecore, we might also want to add the functionality to clear all cached data on any publish. Sitecore itself does clear all the data that it caches using the following event at the end of the publish process:

When we go ahead and implement this, you’ll see that this still doesn’t work!
Here comes the distinction between HttpContext.Current.Cache and HttpRuntime.Cache.

The cache is stored in the session established for the front end site, while we are attempting to clear this cache in a session established for the sitecore editor (a different session). And HttpContext.Current.Cache is not shared across instances. HttpContext.Current.Cache internally does use HttpRuntime.Cache which infact is shared across instances for a given app domain.

Using HttpRuntime.Cache is the key here which will enable us to achieve this functionality. You could define a prefix for the keys which you would want cleared out on publish if you wouldn’t want all the keys in cache cleared.