Actually, we have to use to PerformanceNavigationTiming to get understanding if a page was achieved by the browser button Back. So the code above or below would be as following:
const [entry] = window.performance.getEntries();
if (entry?.type === 'back_forward') location.reload();