Hi Mango,
The law tag on the mattress should include the date that it was manufactured but if your mattress has been compressed for 5 years then it can certainly affect the buildup of VOC’s and offgassing and it can also affect the durability of the foam.
In general a month or so or compression is relatively safe (see post #6 here) and some foam can “handle” longer periods of time but 5 years is much too long IMO.
Phoenix