If you are going to be living or working outside of the UK for a period of less than 5 years, you need to be sure that you don’t fall foul of HMRC’s Temporary Non-Residence Rules.
UK residency is determined based on a combination of factors and the application of the Statutory Residence Test (SRT). Here is an explanation of how it works.