It's been an explosive couple of years for the stock market -- in the trailing 24 months, the big S&P 500 index has handed investors total returns of 42%.

But for tech investors, that number is higher. Much higher.

The tech sector has returned a whopping 67.3% over that exact same time frame, more than 60% better returns than the rest of the overall stock market. Take tech stocks out of the S&P, and the performance gap is even more stark.

That should send an important message for investors contemplating retirement: Tech stocks are a core piece of this market; ignore them at your portfolio's peril.

Picking the best stocks to own for retirement isn't all that different than picking the best stocks to own the rest of the time -- while your risk appetite and income generation needs may change as a retiree, the need to own stocks that contribute to your total return doesn't. That's why adequate exposure to the tech sector is crucial.

Of course, not all tech stocks make sense for your retirement account.

Some of the most volatile stocks that fare well when times are good also come with too much downside risk when bear markets rear their head. The key is striking a balance.

To do that, we're taking a look at a pair of tech stocks and one ETF that makes sense for retirement.

Apple Inc.

Up first is tech behemoth Apple Inc. (AAPL) .

Apple is on track to become the first trillion-dollar company -- a milestone that's only around 9.5% away as of this writing. More impressive, Apple has managed that massive price tag without sporting an equally massive valuation. Shares trade for a PE ratio in the mid teens right now, about a 30% discount to the average tech stock.

That discount looks bigger when cash is factored in. Apple currently carries approximately $162 billion in net cash on its balance sheet, enough to pay for almost a fifth of its market capitalization. Considering the fact that the new tax plan includes low tax rates for repatriated cash, more of that overseas cash balance could soon get unlocked.

Apple's 1.4% dividend yield doesn't make it an "income stock" by any serious means, but it does provide a direct path for shareholder yield, especially given Apple's big cash balance. A combination of a comparatively bargain-priced valuation and cash generation make Apple a perfect tech stock to own for your retirement account.

Apple is a holding in Jim Cramer's Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells AAPL? Learn more now.

Intel Inc.

Another tech stock worth owning for retirement is Intel Corp. (INTC) .

Intel has been ignored to some extent, thanks to the furor surrounding the "FAANG stock" rally of the last couple of years, but that's a mistake. Intel owns the power combination of a deep business moat, consistent profitability, and a discount to the rest of the tech sector.

Intel's ownership position of around 80% of the microprocessor market is huge -- while there's been chatter about the risks of a contender taking share from Intel's core business for decades, those fears haven't materialized. While the mobile chip business has eluded Intel, it's filled the profit gap with success in servers, a corner of the market that continues to grow.

A solid 2.3% dividend payout, plus better-than-industry earnings multiple makes it a solid choice for retirement accounts.

SPDR Technology Select Sector ETF

Finally, the closest thing to a "set it and forget it" solution for retirement investors is a big, low-fee tech ETF like the SPDR Technology Select Sector ETF (XLK) . XLK and its peer funds provide a solid combination of big-cap tech exposure and income with relatively negligible fees.

For investors who don't feel like stock picking, owning a tech ETF like XLK is as close to a no brainer as it gets.

This article is commentary by an independent contributor. At the time of publication, the author was long AAPL.

More from Retirement

How to Really Diversify Your Retirement Portfolio

How to Really Diversify Your Retirement Portfolio

I'm Still Very Worried About My 401(k) in This Market (Part 2)

I'm Still Very Worried About My 401(k) in This Market (Part 2)

What to Do With Your Retirement Portfolio in This Volatile Market

What to Do With Your Retirement Portfolio in This Volatile Market

How the Tax Cuts and Jobs Act Affects Retirement Benefits

How the Tax Cuts and Jobs Act Affects Retirement Benefits

Bond Markets Prep for $230 Billion Wave as Rates Rise, Growth Questions Persist

Bond Markets Prep for $230 Billion Wave as Rates Rise, Growth Questions Persist