For serious offences, the Foreign, Commonwealth & Development Office is obliged to share information with the UK authorities when a prisoner returns to the UK. Information about offences is often shared between countries anyway. The charity Unlock has a very good summary on their website of how this works in practice.