We have created an area where the client can manage their content in the site instead of the admin and for some reason when we create new content the cache seems to get invalidated.
After creating the content if you go to the node in the admin you will see this error near the Link to Document property: Oops: this document is published but is not in the cache (internal error).
Any ideas why this might be happening? Is there a way to check if the item is in the cache after creating it?
This is the method that seems to be causing the issue:
public static int GetOrCreateContentFolder(IContentService contentService, int userId, int parentId, string folderName, string contentTypeAlias)
{
var targetContentFolder =
contentService.GetChildren(parentId)
.Where(c => c.Name.ToLower() == folderName.ToLower())
.ToList();
if (targetContentFolder.Any())
{
return targetContentFolder[0].Id;
}
var contentFolder = contentService.CreateContent(folderName, parentId, contentTypeAlias, userId);
return contentFolder.Id;
}
It seems that you need to publish your new node called "contentFolder".
var contentFolder = contentService.CreateContent(folderName, parentId, contentTypeAlias, userId);
contentService.SaveAndPublish(contentFolder);
Use PublishWithChildren if you need to publish all children too.
See all methods in the ContentService here: https://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With