Umbraco distributed cache not working when saving content in a background thread
Hi,
I'm currently working on a website in a load balanced scenario with one webapp (publisher) for the backoffice and a load balanced webapp with 2 nodes for website (subscriber). Like here.
Everything is working great except when I try to create a new media in a background thread for long running task on the publisher. Like using hangfire or with Task.Run(() => myfunction), the subscribers are not updated. Image.Url() returns null.
The only solution I have at the moment is to go to the backoffice and refresh the memory cache and database cache manually. Then the images will show up on all my subscriber.
So the problem seems to be related to the internal distributed cache of Umbraco. I tried to use the media cache refresher manually but it did not fix the issue
var payload = new MediaCacheRefresher.JsonPayload(media.Id, media.Key, TreeChangeTypes.RefreshNode);
var payloads = new List<MediaCacheRefresher.JsonPayload> {payload};
_distributedCache.RefreshByPayload(MediaCacheRefresher.UniqueId, payloads);
Lastly, if I run the same code in a the main thread, the images load correctly on all the subscribers.
Do you have any ideas on what can cause this issue and if there are any solutions.
Umbraco distributed cache not working when saving content in a background thread
Hi,
I'm currently working on a website in a load balanced scenario with one webapp (publisher) for the backoffice and a load balanced webapp with 2 nodes for website (subscriber). Like here.
https://our.umbraco.com/Documentation/Fundamentals/Setup/Server-Setup/Load-Balancing/index-v8
Everything is working great except when I try to create a new media in a background thread for long running task on the publisher. Like using hangfire or with
Task.Run(() => myfunction)
, the subscribers are not updated.Image.Url()
returns null.The only solution I have at the moment is to go to the backoffice and refresh the memory cache and database cache manually. Then the images will show up on all my subscriber.
So the problem seems to be related to the internal distributed cache of Umbraco. I tried to use the media cache refresher manually but it did not fix the issue
Lastly, if I run the same code in a the main thread, the images load correctly on all the subscribers.
Do you have any ideas on what can cause this issue and if there are any solutions.
Thanks.
Gabriel
is working on a reply...