I recently went to Portsmouth and had the pleasure of a guided tour on board HMS victory. The guide explained how the sailors on average drank 53 pints of beer a week. I only just realised thats 42,400 pints a week collectively. How on earth could they store that much beer on board!?
The guides aboard Victory are great chaps (and ladies), really cracking, but thy sometimes don't contextualize things real well. 53 pints a week is about 6.6 gallons a week, which sounds about right as the daily beer ration was about a gallon a day. Beer was stored by the tun (a measure, for beer, that was at 216 gallons and was literally a big barrel), and the Victory would store many, many tuns, butts, hogsheads, barrels and other measures in its hold. It also, of course, had to store a pound of bread, 8 oz of meat or duff, a pound of vegetables and other rations for every day for every sailor on board.
Beer was a ration for only home waters because of its volume -- sailors were given wine or arrack in the Med and rum in the Caribbean and other overseas areas, as it stored much smaller. No ship could store enough for long service without supply bases and local purchasing, and in fact the British navy's administration and planning, particularly in victualling, was as responsible for its dominance at sea as any other factor.
Very short answer... often they did not. The British maintained what might be called naval 'superbases' ringing the world and they were supplemented by many smaller locations. Even a quick read about the British Empire is littered with mentions of those bases and their acquisition over time. The purpose was to keep and distribute needed supplies including ale. I don't have a source (phone) but I think that the number of very large bases was 32. Today, the US has ... 33.
St. Helena, where Napoleon died, and Diego Garcia are not examples of superbases but give some idea just how far their reach extended. Also, with Diego Garcia, you can see the evolution towards Anglo-American cooperation in the use of those resources. Even tiny specks of land in the oceans were secured--largely to deny shipping resources to other countries.
The bases were foundational resources for the UK up through WWII, then the US after that for 'projecting power' around the globe. Much discussion available on the topic of projecting power.