# Caching with DLC and fan-out building

**URL:** <https://discuss.circleci.com/t/caching-with-dlc-and-fan-out-building/52881>\
**Category:** Build Environment\
**Created:** [March 12, 2025, 8:19am UTC](https://discuss.circleci.com/t/caching-with-dlc-and-fan-out-building/52881 "2025-03-12T08:19:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ely](https://avatars.discourse-cdn.com/v4/letter/e/87869e/32.png) [@Ely](https://discuss.circleci.com/u/Ely)\
**Post date:** [March 12, 2025, 8:19am UTC](https://discuss.circleci.com/t/caching-with-dlc-and-fan-out-building/52881/1 "2025-03-12T08:19:37Z")

</div>

I have a workflow that is building in parallel all the services of my application:

```auto
workflows:
  build-test-publish:
    jobs:
      - prepare_bakefile
      - build_svc1:
          requires: 
          - prepare_bakefile
      - build_svc2:
          requires: 
          - prepare_bakefile
      - build_svc3:
          requires:
          - prepare_bakefile
      - build_svc4:
          requires: 
          - prepare_bakefile
      - build_svc5:
          requires: 
          - prepare_bakefile

```

And each service is built with something like this:

```auto
jobs:
  build_svc1:
    machine:
      image: ubuntu-2204:current
      docker_layer_caching: true
      - run: 
          command: |
            docker buildx bake --progress=plain --file=docker-bake.hcl --file=baked-metadata.json svc1

```

I’m trying to make this setup work properly with DLC, but I cannot figure out a way to make it works: the cache does not seems to be used properly between reruns of the job, is there something obvious I’m missing ?

Also I was wondering if the DLC was scoped to jobs and not to workflow ?

---

<div class="post-metadata">

**Author:** ![james-crowley](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/james-crowley/32/27929_2.png) [@james-crowley](https://discuss.circleci.com/u/james-crowley)\
**Post date:** [March 13, 2025, 12:33pm UTC](https://discuss.circleci.com/t/caching-with-dlc-and-fan-out-building/52881/2 "2025-03-13T12:33:20Z")

</div>

@Ely DLC caching is per job, with some special handling for if you are using `parallelism`. Did you see somewhere in the docs that said otherwise, if so please let me know, so we can get it corrected! (Or make it clear for others)

In your case, if you are using buildx you might need to `name` your builder instance, see [Docker layer caching overview - CircleCI](https://circleci.com/docs/docker-layer-caching/#buildx-builder-instances) for more details.

Lastly, I would encourage you to use the Docker orb, [CircleCI Developer Hub - circleci/docker](https://circleci.com/developer/orbs/orb/circleci/docker), which would handle this for you.
