It's time in the market -- not timing the market -- that leads to life-changing wealth. Stocks may rise or fall on any given day for any number of reasons, but it's impossible to predict those short-term fluctuations. However, the S&P 500 has generated an annualized return of 8% over the last 50 years, meaning stocks have the ability to create significant wealth over long periods of time.

For that reason, a buy-and-hold strategy is the best course of action. And Zscaler (ZS -2.12%) and Elastic (ESTC -1.59%) look like smart stocks to buy right now. Both of these tech companies benefit from sizable market opportunities, and I think shareholders could see fivefold returns over the next decade.

Here's why.

Businesswoman reading a document while sitting at her computer.

Image source: Getty Images.

1. Zscaler

Traditionally, organizations have stored sensitive data and applications in private data centers. And to protect those resources, all traffic was routed through central hubs where security policies were enforced. However, that approach is no longer practical. Many of those sensitive corporate resources now live in the public cloud, and routing all traffic through a private data center causes network performance to deteriorate.

Zscaler solves that problem. Its cloud security platform -- known as a secure access service edge (SASE) -- spans 150 data centers worldwide, meaning it can handle far more data than the average corporate network. Zscaler uses that infrastructure to inspect traffic and enforce securities policies in the cloud, and it leans on artificial intelligence to identify and block unknown threats. In short, Zscaler allows employees to quickly and safely access corporate resources from any location, on any device.

More importantly, the company has built a strong moat around its business. Research company Gartner has named Zscaler the industry leader for the last 10 consecutive years. And those accolades have come alongside strong financial results. In the most recent quarter, Zscaler surpassed 5,600 customers, up 32%, and average customer spending increased by more than 25%. As a result, trailing-12-month (TTM) revenue soared 58% to $761 million, and free cash flow skyrocketed 205% to $184.9 million.

Looking ahead, shareholders should expect Zscaler to maintain that momentum. Cybersecurity will only become more critical as enterprises become more digital and workforces become more mobile. And with a $72 billion addressable market, according to management, fivefold growth over the next decade seems entirely plausible. In fact, if Zscaler can maintain sales growth of 30% over that time period, the company could achieve a market cap of $183 billion (five times what it is today), with a price-to-sale ratio of 18 -- the stock currently trades at 47 times sales.

2. Elastic

Elastic brands itself as a search company. At the core of its platform is Elasticsearch, an analytics engine that can store and query data from virtually any source across the corporate ecosystem. Organizations can use the platform to create custom software, or they can access three pre-built applications: Enterprise Search, Observability, and Security.

Enterprise Search is a workplace search engine that helps employees find corporate content quickly, and it allows developers to add search bars to websites and applications. Observability helps IT teams identify infrastructure performance problems, and Security helps organizations defend against cyberattacks. All three products are powered by Elasticsearch, which itself ranks as the most popular enterprise search engine by a wide margin, according to DB-Engines.

That popularity has translated into strong financial results. Elastic surpassed 17,000 customers in the most recent quarter, growing its clientele by 32%. And that average customer spent almost 30% more over the past year. As a result, TTM revenue climbed 44% to $733.8 million, and the company posted positive free cash flow of $15.5 million.

Looking ahead, Elastic should benefit from digital transformation. As enterprises continue to deploy new technologies and generate more data, tools like Elastic Enterprise Search, Observability, and Security will become increasingly relevant. In 2021, management valued its addressable market at $78 billion. And given Elastic's strong competitive position, I certainly think this company -- which currently has a market cap of $8.7 billion -- could grow fivefold over the next decade.