This is a frequent topic over on the 996/Boxster RL forums as well as many BMW forums. As others just said, it depends on how far the lens have deteriorated.
I tried a metal polish yesterday (P21S) on my X5 lights and only got a modest improvement. If someone can recommend a better one, I would like to try it. The alternative is sanding / polishing the lens but that removes the UV protection. I found a kit that includes a UV protection compound, but I think the only viable long term answer would be something like
XPel lens covers. They are expensive at $70, but way less than a new
factory headlight unit.