When building a Docker image, each line in the _dockerfile_ represents the building of a layer in the image layer stack, and when we run the `docker build -t [image_name]` command, Docker checks for any modification in each layer and decides whether to add the layer from scratch or to load it from the file system's cache, hence saving you significate build time.
One consequence of this feature is that a change in a certain layer forces docker not only to re-build the modified layer itself, but also the layers that come after it.
Example:
_node_ developers should place the `RUN npm install` command before the `COPY . .` command to ensure that a change in the source code does not require a re-run of `npm install` and a redundant update of _npm_ packages.
#Before
COPY . .
RUN npm install
#After
COPY package.json .
RUN npm install
COPY . .