Xpel headlight film will help prevent yellowing of the lens. I have been using it for years.
I used Lamin-X on my commuter car shortly after I bought it (brand new). After 4 years, the Lamin-X was faded and yellowing. Peeled it off and had brand new factory-fresh headlights underneath.
I just ordered Xpel Ultimate Plus to replace the Lamin-X. I've also tried 3M basic (red letter backing) which sucked. It's not very pliable.
Not sure why, but some plastic lenses stay clear MUCH longer than others.
One of my relatives had a '95 Maxima with lenses that still looked great 20+ years after they were manufactured - despite having never received any special care. I've noticed the same thing about other Maximas of that vintage, too.
The design of the headlights and how they meet the hood I think is a factor. A relative of mine has a post-refresh 1st-gen Ford Edge (2012ish) and the headlights look brand new, despite being parked outside since new and only receiving Costco car washes once a month or so. I took a closer look and realized that there is a chrome plastic trim piece above each headlight which casts a thin shadow on the top edge of the lens. I think that protects the top edge from sun exposure and peeling.
Conversely, on my Honda, the headlights are like bug-eyes. They have a top surface that is lined up with the flat part of the hood.
One of my relatives has a Mazda Miata ND. Those headlights are recessed in a good 1/4" behind the leading edge of the hood. I'm thinking they'll be looking good for years.