Preheat oven to 190°C (375°F) and lightly butter a 9x13-inch baking dish.
In a saucepan, melt butter over medium heat and stir in flour until smooth.
Slowly whisk in warm milk and cream, stirring constantly until thickened.
Add garlic, salt, and pepper, then remove from heat.
Layer half the potatoes in the baking dish, pour half the sauce, and repeat with the remaining potatoes and sauce.
Sprinkle cheese on top if using.
Cover with foil and bake for 40 minutes, then uncover and bake for another 20 minutes until golden and bubbly.
Let it rest for 10 minutes before serving so the sauce thickens nicely.