If you have several-years-old iPhone, or know someone who does, you’re probably aware of the fact that the battery life is a lot shorter than when it was new.

The rechargeable batteries in today’s electronics degrade over time and become less capable of holding a charge or delivering the same peak power.

This caused Apple to limit the performance of older phones in order to prevent unexpected shutdowns, which led to class-action lawsuits, and ultimately a rather good $29 battery replacement program.

In iOS 13, Apple’s introducing a new feature called Optimized Battery Charging that should help slow the rate at which the battery in your phone wears out. It’s not going to help your battery last longer on a single charge, but it’s going to help your battery hold the same amount of charge over the years you own it.

Batteries age over time

In the Tesla electric car, its default is set to stop charging when the battery is 90 percent full. You can use the app to change this (up or down), but the default is there for a good reason.

As lithium-ion batteries are charged and discharged, the chemical structure in them breaks down. Over lots of charge-and-discharge cycles, they become unable to hold as much charge or deliver as much power all at once.

This phenomenon is accelerated when your battery is charged to its maximum capacity. Tesla sets a default charge limit in order to preserve the health of the battery over time. If you think it’s annoying for your iPhone to die after 8 hours instead of 12, and expensive to replace its battery, think about losing 80 miles of driving range or replacing your car’s battery!

Slowing aging by limiting charging

The new Optimized Battery Charing option in iOS 13 is meant to do the same thing as Tesla’s default 90 percent limit—reduce battery degradation over time by not fully charging when you don’t have to.

It works a little differently, though. Instead of a fixed cap, Apple is using intelligence to figure out when you need a full charge and when you don’t. Apple describes it like this:

A new option helps slow the rate of battery aging by reducing the time your iPhone spends fully charged. iPhone uses on-device machine learning to understand your daily charging routine so it can wait to finish charging past 80 percent until you need to use it.

Let’s say that, by analyzing your usage habits, your iPhone has determined that you always plug in your phone around 10 p.m. and leave it plugged in until 7 a.m. the next morning. One day, you plug in at 4 p.m. It’s likely that your iPhone will only charge to 80 percent, because (based on your past usage) it knows that much charge will easily take you to your usual 10 p.m. charge time.

That’s probably an oversimplification. Apple’s algorithm is probably quite conservative, because nothing would be worse than running out of charge because your iPhone decided you would only need 80 percent, and was wrong.

The hope is that, with this feature enabled, you don’t actually experience any real practical difference in how often you need to charge. But, after owning your phone for three or four years, the battery might hold 80 to 90 percent of the charge it did when it was new, instead of 50 to 60 percent, so you don’t need to replace it.

How to set Optimized Battery Charging

In the current iOS 13 beta build, the Optimized Battery Charging feature is disabled by default. If testing goes well, it wouldn’t be surprising to see Apple make enabled the default setting, provided it gives a clear and obvious explanation of why your battery might stop charging at 80 percent.

If you want to enable it (and you probably should), this is what you do:

Open the Settings app. Tap on the Battery category. You’ll see a bunch of battery stats and a “Low Power Mode” toggle up top. Tap on Battery Health. In the Battery Health section you’ll see a representation of how much maximum capacity your battery has left—a good indication of how far it has degraded—along with the toggle for Optimized Battery Charging.

IDG To enable Optimized Battery Charging, you have to dig a few levels deep into Settings.

With Optimized Battery Charging enabled, you might sometimes see your battery stop charging at 80 percent, but don’t freak out! Don’t wait too long trying to make it charge higher, just use your phone as normal. If Apple’s intelligence about your battery use habits is correct, you shouldn’t run out of charge. If you do, be sure to use the Feedback app to let Apple know that its beta software isn’t behaving as you expect.

Other tips for improving battery longevity

Your battery wears out from more than just charging and discharging or holding on to maximum charge. Your iPhone has sophisticated charging circuitry to help keep the battery in good health, so you shouldn’t be expected to do much to keep that battery working well. Still, here are some other tips that may help keep your iPhone’s battery working its best for as long as possible.

Avoid excessive heat. Charging up your phone in very hot car is a bad idea, for example.

Rapid changes from very cold to very hot are bad for your battery, too.

Try not to let your battery completely discharge. Keeping it above 20 percent or so, if possible, may help it last longer.

If you’re going to leave your phone unused for a week or more, run down the battery until it’s below 80 percent and above 30 percent, then power it down completely.

Know your usage habits, and don’t fully charge your iPhone when you don’t need to, even if the Optimized Battery Charging feature might charge it further.