Heat the oil or butter in a large skillet over medium heat; add the onions and cook, stirring often, until caramelized, about 25-30 minutes. Side Note: Add a few tablespoons of water if the onions run dry while cooking.
Add the minced garlic and season with sea salt and freshly cracked pepper, and cook, stirring constantly, for an additional 1 minute.
Preheat the oven to 350 degrees. Coat a large baking dish with butter or olive oil cooking spray.
Slice the potatoes with a mandolin.
Layer the dish with a portion of the potatoes. Cover the slices with half of the caramelized onions, then sprinkle with some cheese. Repeat with a second layer, and finish with a final layer of potatoes.
Heat the milk and butter in a small saucepan until the butter is melted.
Pour the milk mixture over the potatoes, season the top with freshly grated nutmeg, sea salt, and freshly cracked pepper to taste. Sprinkle with the remaining cheese and cover with foil.
Bake for 45 minutes, until the potatoes are tender and the casserole is bubbly.
Remove the foil and place it under the broiler for a few minutes to brown the top.