Liberals are shocked (shocked!) that Rep. Paul Ryan (R-Wis.) and his co-partisans would consider cutting Medicaid, food stamps, Pell grants and other programs that serve the neediest Americans. They have accused Ryan of trying to balance the budget on the backs of the poor.

But long before Ryan unveiled his “Path to Prosperity,” politicians of both parties had been redistributing government spending away from the truly destitute and toward everyone else.

In the past few decades, the federal social safety net has gotten lusher and, on its face, more generous. Spending on the major safety-net programs nearly quadrupled between 1970 and 2010, and that’s after adjusting for inflation and population growth, according to calculations by Robert A. Moffitt, an economics professor at Johns Hopkins University. He included both “means-tested” programs that are explicitly intended to combat poverty (such as food stamps, Medicaid, housing aid, Head Start, Temporary Assistance for Needy Families and the earned-income tax credit) and social insurance programs (Medicare, Social Security, disability insurance, workers’ compensation and unemployment insurance).

There have been, however, winners and losers during that massive expansion.

Since the mid-1990s, the biggest increases in spending have gone to those who were middle class or hovering around the poverty line. Meanwhile, Americans in deep poverty — that is, with household earnings of less than 50 percent of the official poverty line — saw no change in their benefits in the decade leading up to the housing bubble. In fact, if you strip out Medicare and Medicaid, federal social spending on those in extreme poverty fell between 1993 and 2004.

1 of 148 Full Screen Autoplay Close Skip Ad × The best editorial cartoons of 2014 (so far) View Photos A collection of cartoons from around the country. Caption A collection of cartoons from around the country. Lisa Benson/Washington Post Writers Group Buy Photo Wait 1 second to continue.

Then, during the Great Recession and not-so-great recovery, automatic stabilizers kicked in and Congress passed new, mostly temporary, stimulus measures (such as unemployment-insurance benefit extensions). As a result, spending on the social safety net increased sharply and this time for a broader swath of Americans, including the very poor, “near-poor” and middle class. But it still rose more for people above the poverty line than it did for the very poor, Moffitt found.

Other public policies not captured by Moffitt’s calculations have also effectively diverted funds away from the very poorest Americans. Consider the rise of “merit-based,” non-means-tested financial aid at public colleges or the increasing number of tax breaks and loopholes known as “tax expenditures,” more than half of which accrue to the top income quintile.

So why are we robbing the poor to pay the middle class (and rich)?

To some extent, demographics are to blame. Social Security and Medicare are the biggest safety-net programs in raw dollar terms, and both are awarded to elderly Americans regardless of financial need, though Social Security is modestly progressive. As the country ages and health costs rise, these programs get bigger — and end up crowding out other spending that specifically targets the very poor.

Federal disability rolls have also grown dramatically in recent decades. As with Medicare, people don’t have to prove they’re poor to receive Social Security Disability Insurance, so the expansion of SSDI has disproportionately benefited middle-class and “near-poor” families, at least relative to other programs that do means-test.

But ideology, too, has played a major role in the reallocation of safety-net spending.

Since the early 1990s, politicians have deliberately shifted funds away from those perceived to be the most needy and toward those perceived to be the most deserving. The bipartisan 1996 welfare reform — like the multiple expansions of the earned-income tax credit — was explicit about rewarding the working poor rather than the non-working poor. As a result, total spending per capita on “welfare” slid by about two-thirds over the past two decades, even as the poverty rate for families has stayed about the same. Many welfare reformers would consider this a triumph. If you believe many of the poorest families are not out of work by choice, though, you might have a more nuanced view.

Meanwhile, there is probably greater political cover for expanding the safety net for the middle class (that is, the non-destitute). As mid-skill, mid-wage jobs have disappeared — what’s known as the hollowing-out of the labor market — middle-class families have lost ground and are demanding more government help. These middle-class families, alongside the elderly, are also substantially more likely to vote than are the poor. The feds have whittled away at welfare, and (almost) nobody has said boo; touch programs that the middle class relies on, and electoral retribution may be fierce.

On some level, politicians of both parties have understood this political calculus for decades. Ryan’s “Path to Prosperity” just takes it to its logical conclusion.