0

we have some sites running Umbraco9, where we have a few templates that are updated by outside developers. We are hooking up to an FTP and downloading their templates (.cshtml), and in backend their editors can choose from these templates to be inserted in a partial.

var setting = JsonConvert.DeserializeObject<CustomTemplateSettings>(Model.Value); // Getting the settings
thetemplate = setting.templateName;// Getting the selected template
showContent = _service.TemplateExists(thetemplate, forcereload);// Checking the selected template exists (physically), possibly downloading it to server 
            thetemplate = "/Views/CustomViews/" + thetemplate; // creating the path to the template
//Calling template - with some data
<partial name="@thetemplate" model="Model as ContentStructureField" />

Everything is great.... until they want to update their templates. Umbraco has them cached, and I need to either recycle App or hit save on a random Document Type in settings.

I have tried different things, like using @Html.Partial, @Html.CachedPartialAsync, using the tag. I cannot find a way to affect the lifespan or refresh the content of the partial

All googling results in explanations on how to cache specific content. And most Umbraco 9 specific documentation seems to have been lost with the emerging of version 10/11

I need some way to refresh the cache like when saving Document Templates. I do not care about the momentary effect on website performance, as the updates can be planned by the external developers to be non-peak hours.

Thanks in advance

Steen
  • 2,749
  • 2
  • 20
  • 36

1 Answers1

0

Cannot figure out how to delete the question....

Turned out, that I had constructed the path to the template with a double slash ("/Views/CustomViews//TemplateName.cshtml")

While rendering engine did manage to handle this error and show the content apparently the cache did then not properly subscribe to changes to the file and kept the cached version, requiring a complete flush. Fixing the error in the path made the issue go away.

Steen
  • 2,749
  • 2
  • 20
  • 36