Inner cables tend to break relatively early after ~5000km depending on circumstances and how much you shift. I think it got worse with modern shifters with cable housing below the handlebar tape. The cable starts to break and fray inside the shifter.
Usually you notice because the rear derailleur doesn’t shift to the smallest sprockets anymore and it gets worse and worse until the cable snaps or completely seizes up.
So you have some warning and usually are able to ride home just fine. Getting the frayed cable out can sometimes be a bit of a hassle.
A rear derailleur with broken cable will shift to the smallest (hardest) sprocket which can be problematic for getting home. Cable ties can allow you to fix the cable in place so the derailleur stays in an easier (but fixed) gear. A front derailleur will shift to the smaller chainring which is usually fine for getting home.
If you are planning a longer trip and your cables are already used a lot it could make sense to replace them just in case. Otherwise I’d use them until they start to fail.