Cache is not invalidating
# help-with-umbraco
i
I have a website with a couple of environments. I sync content from stage to production. The content, shows up in production back office successfully. Normally, this where the cache would auto-magically invalidate. However, for some reason, this is no longer happening. So I have to click the button found in the back office at Settings > Published Status > Reload Memory Cache. There is some default language located here about this being a 'minor Umbraco issue' if you have to click this button. I don't really know what that means. I'm a little in the weeds here about how to troubleshoot this. I have tried updating the server, the site, redeployment and purging the existing cache. However, I am unfamiliar with the exact process by which Umbraco self-invalidates the memory cache. I could write something to manually invalidate that cache but it feels buying an expensive set of gloves just to flip a light switch. I assume I have simply missed something simple somewhere and I'm losing my mind over it. To be clear, this was working fine, no changes to the system. Umbraco simply stopped auto-invalidating the cache one day. I don't have any specific settings applied to manage the cache. I never needed them before. It just did what it was supposed to do. I would greatly appreciate some advice if anyone else has some words of wisdom to share. Thank you. Umbraco version 13 LTS latest version.
Does anyone have any advice on this one?
a
How are you syncing the content? Umbraco Cloud, Usync Content, or some other way ?
i
I’m using dotmimsync library. Basically simple console app and it just shoves the changes from one db to the other. We have been running it this way successfully in version 7, 10 and 13. Umbraco was automatically picking up a change and invalidating the cache. But for some unknown reason this is not working and I’m not really familiar with that process’s requirements to trigger as it has always worked previously without need to evaluate.
n
Is the umbracoCacheInstruction table being synced. Are the Machine Names the same in each environment?
j
This kind of synchronisation isn't supported and I'm amazed that you've not run into bigger problems before now. Umbraco is built assuming that, at least for certain tables, there will only ever be a single Umbraco instance/application writing to those tables at any given time. Umbraco doesn't "look" for changes to invalidate a cache because it knows it's the only thing writing to those tables. Even if the umbracoCacheInstruction is synchronised correctly there's no way to account for race conditions when synchronising directly over SQL, certainly not between two instances that are both running. If you need to synchronize content between environments I'd recommend uSync Complete (or just uSync if you don't mind managing some extra steps), or Umbraco Deploy. They synchronize content using Umbraco's own APIs and will make sure caches are invalidated properly (amongst other things).
i
Yes, the umbracoCacheInstruction table is synced. The machine name is not the same. Never has been. So, I think what I’m looking for is a way to ensure that umbraco does invalidate in memory cache. My database syncs seem fine - the only problem is that I’m stuck manually invalidating the cache. So I was trying to better understand umbraco’s built in trigger for this so that I can better understand the information gap that I am inside of. I see documentation that outlines clearly how to do this in memory cache dumps but I’m curious what should be happening natively - I have not found that yet. I’m was more poking about wondering if anyone was intimately familiar with those details or know what I should be reading. It obviously has something dedicated to this process or it would have never worked to begin with? At least it seems like a safe assumption.
j
The umbracoCacheInstruction will be what's triggering the cache changes. Whenever content is saved in Umbraco, an instruction is added to that table to tell other Umbraco instances to update their cache. This exists for load balancing, so that other "client" Umbraco instances can update their caches when the backoffice/writing instance makes changes to content. This won't rebuild the entire cache though - only the content that has changed (based on ID). Cache instructions are processed based on a "last seen" ID - which each instance tracks separately. Like I said, there's no accounting for race conditions here. If all of your content changes on the staging environment have added cache instructions with IDs lower than the last seen on your production instance those cache refreshers will not fire. Of course, you also need to make sure that the content is synchronised before the relevant umbracoCacheInstruction, else you'll have race conditions there too. If you want to keep syncing this way then I think you'll just need to rebuild the cache after every sync. You can do it programmatically if you need to. But I will point out again that this scenario is unsupported, and a bad idea. Various Umbraco features and packages may not work as expected.
29 Views