Heat the oven to 400 °F and grease a 9x13-inch baking dish with butter or cooking spray. The dish should be fully coated so the edges release easily after baking.
Cut the potatoes into slices about 1/8 inch thick with a mandoline or a sharp serrated knife. Uniform slices matter because thick pieces stay firm while thinner ones can disappear into the sauce.
Melt the butter in a large saucepan over low to medium heat, then add the diced onion and cook for 5-7 minutes. The onion is ready when it turns soft and translucent without taking on dark color.
Stir in the flour and cook it for 1 minute, then slowly whisk in the milk followed by the heavy cream. The sauce should look smooth and lightly thickened, enough to coat the back of a spoon.
Mix in the Dijon mustard, season with salt and black pepper, then add the shredded cheese over low heat and stir until melted, about 1 minute. Once the sauce looks silky and unified, take it off the heat and keep it covered so it stays warm.
Arrange a layer of potato slices in the baking dish with slight overlap, season with salt and pepper, and spoon some sauce over the top. Repeat the layers two more times, finishing with sauce so the top stays moist as it bakes.
Cover the dish with aluminum foil, set it on a parchment-lined half sheet pan, and bake for 90 minutes. By the end of this stage, the potatoes should be nearly tender and the pan will usually have bubbling edges.
Remove the foil and bake for 20 minutes more to brown the top and fully bubble the sauce, adding a handful of shredded cheese on top if desired. The surface should look golden in spots and the sauce should bubble around the rim.
Let the casserole rest for 10-15 minutes before serving, then finish with fresh parsley if desired. This pause helps the sauce thicken so a spoonful holds together instead of running across the plate.