A key benefit of having a long investing time frame is that you can afford to pay a bit of a premium for any given stock. Looking back over a few decades, you likely won't remember that the shares you purchased had been rallying before you established your position, but you'll be glad you had the stock in your portfolio to compound for all that time.

Of course, not all winners keep on winning. The hard part is separating businesses that have what it takes to grow for decades from the ones that are rallying due to a temporary spike in optimism on Wall Street.

With that core challenge in mind, let's look at a few stocks that have a clear shot at more market-thumping shareholder returns in the coming decades.

1. Netflix

It's still early days in the stampede toward streaming television, and Netflix (NFLX -0.63%) remains the best choice for investors seeking exposure to this shift. The streaming video giant thrilled Wall Street in late January by announcing its best quarter yet for subscriber growth. Membership levels swelled to 260 million from 247 million in the previous quarter.

That figure could be much larger in a decade or two. Netflix accounts for just 8% of total TV screen time right now in the U.S., its most developed market. Its share of the wider advertising, game, TV, and film markets is even smaller at about 5%, management estimates. Netflix is aiming to boost these levels over the next several years, targeting a $600 billion-plus annual revenue opportunity.

Management isn't asking shareholders to put up with weak financial results in the meantime, either. Operating profit margin is holding above 20% of sales, and annual cash production has improved from a $3.3 billion outflow in 2019 to $6.9 billion of positive cash flow in 2023. Netflix is increasingly using that excess cash to buy its stock, and investors should consider doing the same thing.

2. Palo Alto Networks

There are some good reasons behind the recent rally in Palo Alto Networks' (PANW 0.91%) stock. The cybersecurity giant is seeing excellent growth these days, with sales on track to rise by nearly 20% this fiscal year after soaring 25% in fiscal 2023.

These gains reflect market-share growth in a competitive and fast-growing industry that's likely to expand for many years as more work processes move online and as digital threats proliferate. "An unprecedented level of attacks is fueling strong demand in the cybersecurity market," CEO Nikesh Arora told investors in mid-November.

Palo Alto faces well-funded competition for this enterprise demand, including from companies like Microsoft that offer comprehensive software service platforms.

Yet Palo Alto is holding its own in this competitive environment, partly by innovating quickly to protect its lead as a pure-play cybersecurity provider. And shareholder returns should benefit from its improving finances as well.

Palo Alto Networks is boosting profit margins right now even as cash flow rises to an estimated 40% of sales in fiscal 2024. Combined with the potential for much higher revenue in a decade or two, this software-as-a-service specialist seems worth the premium Wall Street has placed on its stock.