Is it possible to build without layer caching but keep buildkit's --mount=type=cache

I’d like to be able to build an image, or at least some RUN steps, without layer caching like --no-cache. The problem I’m facing is that --no-cache seems to effectively abandon --mount=type=cache.

I think this may have changed in recent versions. I feel sure I tested this a few months back and got a different result.

The use case here is for steps that install package from external repositories. Eg: apt-get update && apt-get install ... or pip install .... In my CI pipeline I want to run these without docker skipping the step, but I want buildkit to keep the local file cache because they run a lot quicker with a lot less data usage.

Is there any way to switch off layer caching but keep buildkit’s mounted cache directories?