Forget the faithful hound. The animal that has been most truly loyal to humans throughout history has been that quiet freeloader, the intestinal worm – a tiny beast that has stuck with us through rich and poor, war and peace, feast and famine.

We haven't always made it so easy for our chummy parasites, though. According to a team of British archaeologists, our relationship with gut helminths has varied considerably throughout the ages.

Determining exactly when and why worm infections fluctuated across time could tell us a thing or two about managing infestations today, a problem that continues to affect the health of nearly a quarter of the world's population.

There's quite literally a crap-load of evidence detailing the kinds of parasites that crammed into our guts at key moments of history. Thanks to their hardy and easily identifiable eggs, blood-sucking worms of many different kinds and creeds have been traced in the mess left behind in latrines and chamber pots.

This conveys the problem on a general population level, but it doesn't tell us much about the prevalence among individuals harboring them.

To dig deeper into the demographics of intestinal worm infections, the researchers behind this recent investigation analyzed the remains of 464 humans buried at 17 sites around the UK, all dating from prehistoric to industrial periods.

In more than a quarter of the bodies, they uncovered clear signs of nematodes (roundworm) belonging to the genuses Ascaris and Trichuris and food-transmitted cestodes (flatworms) Taenia and Diphyllobothrium latum.

By far the most common wriggler was the roundworm, Ascaris. Even today, this parasite is a common form of infection, making itself at home in around a billion people's guts and putting the growth and development of young children at risk.

A great time to be a roundworm was during the Roman occupation, particularly in Canterbury. In spite of having a reputation for sanitation and love of a good social chat while defecating (or perhaps because of it), more than one in five Romans would have carried a churning gut full of Ascaris worms.

Similar percentages of infection were among bodies buried in Anglo-Saxon and High Medieval Ipswich, and in Industrial London.

Roman and High Medieval periods were both glory days for roundworms and whipworms all over the land, it seems, with infections peaking in late medieval times.

Why infestations hit such highs and then dropped, we can only speculate. Shifts in how waste was managed, urbanization, changes in trade routes…all could have played a role.

With London's citizens being an exception, many in the UK seemed to benefit from the revolution in sanitation that took place in the 18th and 19th centuries. The numbers of infected varied considerably from place to place, suggesting some measures were having a profound effect on parasite movement.

Flatworm infestations provided insights into the culinary habits of populations throughout history. Passed through different food items, such as freshwater fish or pigs and cattle, finding them together in four out of six sites provided clues to the local diet.

More interesting yet was the fact tapeworm eggs were only detected in adults, a finding that has been noticed before and attributed to long-lived infections built up over time.

Large-scale anthelmintic medication distribution is central to mitigation of worm infections throughout modern impoverished nations. Though effective, it relies on repeated doses in the face of reinfection from a contaminated environment.

By linking cultural and technological differences with the prevalence of infections, future researchers could identify the best ways of managing parasites without leaning heavily on drug-based therapies.

This research was published in PLOS Neglected Tropical Diseases.