The S&P 500 has gained 17% year to date after a constellation of factors has lifted investor sentiment, including better-than-expected earnings and stronger-than-expected economic growth. The index is now just 6% below a record high, a portentous threshold that (once crossed) signals the onset of a new bull market.

So what? The S&P 500 returned an average of 186% during the last nine bull markets, and it will undoubtedly produce considerable gains during the next one. Investors looking to capitalize on upward momentum in the S&P 500 should consider two index funds: the Vanguard S&P 500 ETF (VOO 1.00%) and the Invesco S&P 500 Quality ETF (SPHQ 1.42%).

Both index funds are linked in some fashion to the S&P 500, meaning they should move upward with the index during the next bull market, and both have made money like clockwork over the last decade. Here are the details.

Vanguard S&P 500 ETF: Up 229% over the last decade

The Vanguard S&P 500 ETF measures the performance of the S&P 500 index, which tracks 500 of the largest U.S. companies based on market capitalization. The index fund spreads capital across value stocks and growth stocks from all 11 market sectors, and it covers about 80% of the entire U.S. equity market, which makes it a good barometer for the broader U.S. economy.

Warren Buffett sees that as a compelling investment thesis. He has frequently opined that S&P 500 index funds are the best option for most investors, once explaining his rationale like this: "American business -- and consequently a basket of stocks -- is virtually certain to be worth far more in the years ahead."

Indeed, the Vanguard S&P 500 ETF returned 229% over the past decade, or 12.6% annualized. That means $150 invested weekly during that time period would be worth $155,500 today. Finally, the index fund bears a very low expense ratio of 0.03%, meaning the annual fee on a $10,000 investment would total just $3.

Invesco S&P 500 Quality ETF: Up 240% over the last decade

The Invesco S&P 500 Quality ETF measures the performance of the S&P 500 Quality index, which itself attempts to track the highest-quality S&P 500 companies as measured by three metrics: return on equity (ROE), balance sheet accruals (BSA) ratio, and financial leverage ratio.

Why are those figures significant? ROE measures how effectively a company turns shareholder equity into profits. The BSA ratio assesses earnings quality by looking for balance sheet manipulations. And the financial leverage ratio measures debt as a percentage of shareholder equity. In general, a high-quality company will have a high ROE, a low BSA ratio, and a low financial leverage ratio.

The Invesco S&P 500 Quality ETF spreads capital across 101 stocks that represent a blend of value and growth. It is more concentrated than the S&P 500, but its constituents are supposed to represent the very best of the broader index. And indeed, the Invesco S&P 500 Quality ETF has topped the performance of the S&P 500 over the last decade with a total return of 240%, or 13% annualized. That means $150 invested weekly during that time period would be worth $159,200 today.

However, the Invesco S&P 500 Quality ETF bears a slightly higher expense ratio of 0.19%, meaning the annual fee on a $10,000 investment would be $19.