In a large skillet over medium heat, add the olive oil, onions and 1 tsp of salt. Stir to combine. Let the onions caramelize for 35-40 minutes, stirring often so that they brown but being careful not to burn.
While the onions are caramelizing, peel your potatoes and slice them into 1/4-inch rounds. I prefer to use a mandolin to ensure they are a uniform ¼ inch thickness, but if you do not have one, you can cut them carefully with a sharp knife in as even slices as you can get!
Add the sliced potatoes to a large bowl and fill with water until they are just covered, set aside (this helps prevent them from browning while you finish your onions).
Preheat your oven to 375℉ and grease a 9x13 baking dish.
Once the onions are caramelized, drain off any excess oil then place back over medium heat.
While the oven preheats, add the garlic and butter to the skillet with the onions. Melt the butter and sauté the garlic for about a minute.
Add the white wine to the skillet and let it cook until it has reduced by half, about 2 minutes. Once reduced, add the heavy cream and whisk to combine and bring to a simmer. Stir in the thyme, white pepper, garlic powder, cayenne (if using) and the remaining 1 tsp of salt. Stir to combine and cook, simmering and stirring often, to allow the flavors to mend and the sauce to slightly thicken, 4 more minutes. Remove from heat and set aside while you begin to layer your potatoes.
Drain the potatoes then add ½ of the potatoes to the bottom of the greased 9 x 13 pan in an even layer. Pour ⅓ of the sauce over the first layer of the potatoes (about 1 cup) then add ¼ cup of the cheese. Next, add the remaining potatoes then pour the remaining sauce over (do not add the remaining cheese yet!)
Cover with foil and transfer to the preheated oven and bake until the potatoes are just fork-tender, about 40 minutes.
Once tender, carefully remove the potatoes from the oven and increase your heat to 425℉.
Remove the foil and top the potatoes with the remaining ½ cup of cheese. Place back into the oven and cook, uncovered, for 8 to 10 minutes, or until the cheese is bubbly and lightly browned over the top.
Let cool for 5 to 10 minutes before serving! Enjoy!