Is there any way to render only "what changes" in a frame?

I’ve been wondering about ways to save render times, and does anyone know if there is a script that can check the changes between frames and only re-render the parts that need to be updated? I kind of already do this manually, for example if a character is animated but the background is still and there is no camera movement then I usually render one frame with the bg then the rest is only the part of the screen that needs to be re-rendered until the camera moves. I’m curious if there is any way to automate it?

If you make use of render layers, you can just render the layer/layers that changed by clicking this button in teh compositor.

Can you elaborate?