A build that keeps using an old layer is usually doing what the cache rules tell it to do.
docker build --no-cache --pull -t app:test .
docker builder prune --filter until=72h
--no-cache ignores all stored layers, and --pull fetches a fresh copy of the base image first. That is a heavy way to fix one stale step like apt-get install or a git clone. To refresh only from one point onward, put an ARG with a changing value in front of that line, for example --build-arg REFRESH=$(date +%s). docker builder prune --filter until=72h deletes build cache entries older than three days and asks for confirmation first.
Further reading: Docker docs: Build cache
Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it