Petra Liljecrantz
Mar 22, 2016
  5995
(4 votes)

Differences between scheduled publish and normal publish

This is the third post on issues I encountered working for Episerver Managed Services and this time it´s about scheduled publish. One question that we got fairly frequent was about the scheduled publish job. Partners had issues of different kind (pages not publishing, cache not working etc.) and it was escalated to us. I find that there isn´t a whole lot documented about scheduled publishing so these are some stuff I learnt directly from the developer team. It covers some differences between a scheduled publish and a normal publish done manually by an editor which publishes the page directly.

  • The normal publish uses the users context while the scheduled publish runs without the users context and thus it skips the access check. This could in theory mean that a page can be scheduled for publish by a user that isn´t supposed to be able to publish.
  • The normal publish has access to the HttpContext and the scheduled publish hasn´t, so if a page that´s target for a scheduled publish relies on the HttpContext it will probably have some issues and the publish will most likely fail.
  • The normal publish fires off the publish event which will invalidate the built-in cache so that all load balanced servers will go to the database to fetch the new content, the scheduled publish however does not fire off that event so other load balanced servers will not get the new content until the pageCacheSlidingExpiration has passed (which is by default 12 hours). This setting can be changed in web.config by adding pageCacheSlidingExpiration anywhere in the applicationSettings tag within the episerver tag, like this:
<episerver>
    <applicationSettings httpCacheability="Public" pageCacheSlidingExpiration="7.00:00:00"...
Mar 22, 2016

Comments

Santosh Achanta
Santosh Achanta Mar 23, 2016 04:34 AM

Great, thanks for sharing.

Vincent
Vincent Mar 25, 2016 02:44 AM

Nice article. I didn't realize schedule publishing not fire off event. Do you have any solution make it happen automatically?

Petra Liljecrantz
Petra Liljecrantz Mar 25, 2016 12:52 PM

Thanks!

I haven´t actually tried to force the publish event when using scheduled publish but I doubt that there is a way. I might be wrong though.

Tomasz Madeyski
Tomasz Madeyski Aug 9, 2018 02:03 PM

I found this blog post when I had issues with output cache being not cleared after scheduled publish. I was really surprised that lifecycle events are not fired so I did debug and well... those are fired up. DelayedPublishedJob runs `PublishOnBehalfOf` method which calls regular ContentRepository's Publish method which calls all lifecycle events (i.e RaisePostEvents which then fires PublishedEvent). My issue was (and maybe so was yours) that one of my custom event handlers was throwing an exception. Look at `PublishOnBehalfOf` method (Episerver.Util.DelayedPublishJob):

private void PublishOnBehalfOf(ContentReference contentLink, string user)
{
IPrincipal currentPrincipal = Thread.CurrentPrincipal;
try
{
Thread.CurrentPrincipal = (IPrincipal) new GenericPrincipal((IIdentity) new GenericIdentity(user), (string[]) null);
this._contentRepository.Publish(contentLink, AccessLevel.NoAccess);
}
finally
{
Thread.CurrentPrincipal = currentPrincipal;
}
}


so what happens here is Publish throwing (well, my custom event handler is) and exception. It stops executing other event handlers and it gracefully jumps to finally block with no trace of exception being thrown. (status of Publish Delayed Content Versions is just "Nothing was published." - no error). 

So once I fixed my custom event handler I got all lifecycle events fired up and one of them was probably one responsible for clearing output cache. 

Bottom line is: if status of job is "Nothing was published" when actually it was published than you probably have some issues with you event handlers.

Note: I'm working on EpiServer 10.10.4, I didn't check newer versions

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024