In the UK, a referee (the person who writes you a reference) should be someone best able to attest credibly to your talents in a professional/academic capacity. Always check with the referees beforehand to get their agreement.
Unless you are applying for an academic job or further study, you will typically need two referees. As a student, you should normally get a tutor and a past employer, if possible. They should not be relatives. It is important to contact potential referees ahead of applications to ask them if they are willing to write you a reference. This is also best practice if you need the reference returned by a given date and if you are making multiple applications.
For most non-academic positions, the offer is made and accepted before the references are called for. So typically it is only in academia that the reference needs to be impressive to influence the hiring decision. For most non-academic jobs the reference is a due diligence step.
The UK government website includes helpful information about what to do if you think you've been given an unfair or misleading reference.
We are often asked, for how long after moving on it is still valid to use a referee from your past. There is no general rule but you can help yourself by actively maintaining relationships. Some PhD supervisors and even some tutors become life-long friends with their former students, exchanging greetings cards and socialising periodically. In this case, there is no limit to how long you can call upon someone to be a referee. So always seek to form strong cordial relationships with all contacts in the University and in the workplace.
Julia Hilton, Careers Adviser, says:
In the UK you don't usually have to include referee details in your CV unless you are making an academic application. No matter who you choose as a referee, it's polite to ask them first! References could come from work experience (including micro-internships), extra-curricular activities, professional bodies, charities and voluntary experience, academia (including school) and even through strong LinkedIn connections. Your referee is someone who can champion your strengths and competencies for a given role so always seek to make warm connections in the workplace, even if it's short term experience.