I've read that the shelf life of DEF is one year, but we buy it in bulk and have stored it for years. Deisel exhaust fluid is naturally clear so if it appears cloudy or colored, it’s likely contaminated or old.
Years ago I bought some jugs of DEF from NAPA and poured it into one of my trucks. When I got to the bottom of the container there was an awful lot of crystals in the bottom of the jug ... so much so that the jug spout plugged off. I left it in the truck and ran the truck as normal without any problems. Apparently bad DEF can cause issues.