Distributed umbraco content

Lets assume that you have two umbraco instances

  • A delivery site – publicly accessible site with no access to the CMS admin screens
  • An authoring site – Usually an IP restricted site which has access to the CMS admin panel

Both of these sites will share the same data base and media library.

You have cached content within the application, anything from a list in a HTTP cache to media content and now the data has been updated in the CMS. You can see the content on the authoring site, but you cant see the content on the delivery site until the cache has expired.

There are two publishing events that you can use when updating content to refresh the caches on both instances

  • PageCacheRefresher.CacheUpdated
  • MediaCacheRefresher.CacheUpdated

 

Create a new ApplicationEventHandler in the site and add both of these methods in and expire your caches as required.

When the content is updated in the CMS on your authoring site, it will update the database and call events. This will then call your custom code to clear and rebuild your cache which will enable the delivery site to be updated when content is entered in authoring.

The documentation still needs updating here https://github.com/umbraco/UmbracoDocs/issues/324 

Umbraco with https on Azure and scheduled published tasks

When forcing a site to run on HTTPS, the following rule is set in the web.config to force a site to 301 redirect to HTTPS when a HTTP link is found

  <rule name="Redirect to https" stopProcessing="true">
 <match url="(.*)" />
 <conditions>
 <add input="{HTTPS}" pattern="off" ignoreCase="true" />
 </conditions>
 <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />
 </rule>

Whilst initial test will force the site to redirect to HTTPS, not all requests made from umbraco will execute using just this. We also need to ensure that the following key is also set

<add key="umbracoUseSSL" value="true" />

You must also make sure that set the location of the Umbraco endpoint in the umbracoSettings.Config

  <web.routing
 trySkipIisCustomErrors="false"
 internalRedirectPreservesTemplate="false" disableAlternativeTemplates="false" disableFindContentByIdPath="false"
 umbracoApplicationUrl="https://mysite.localhost/umbraco">
 </web.routing>

This will ensure that all requests made from umbraco to /umbraco/RestServices/ScheduledPublish/Index will be sent via HTTPS in the first instance.

When this is not set, a HTTP request is made which will result in the error

A public action method ‘Index’ was not found on controller ‘Umbraco.Web.WebServices.ScheduledPublishController’.

The error indicates that a request has been made via HTTP and redirected to HTTPS which has been rejected.

Once the App Setting has been set, the error will resolve.