Age of information (AoI) is a concept that represents the degree of freshness that a monitor has about a remote source of information. Mean AoI and peak AoI can be used in Cyber–Physical Systems (CPS) to optimize, evaluate, and scale different types of applications. Packet management techniques are used to optimize AoI-related metrics, prioritizing, blocking, or preempting (drop and replace) packets. State-of-the-art techniques for AoI optimization, like LGFS-S (Last Generated - First Served - preemption in service) and LGFS-W (preemption in waiting or no preemption) are static, since their mechanisms always perform the same action, regardless of the system state. To achieve better performance using packet management techniques to optimize AoI metrics, this study presents two stateful techniques, which perform conditional preemption decisions on packets based on system state variables, like the mean residual service time (MRST). The two proposed techniques are LGFS-C (Last Generated - First Served - Conditional) and LGFS-C-peak. The analytical and experimental results show that both techniques achieve equal or better results than the state-of-the-art techniques in optimizing AoI and may improve the CPS performance for monitoring and decision-making applications.