Gitlab CI carry cache between stages/steps

Hello,

Can somebody help me understand how cache works please ?

I’ve constructed something like that:
cache:
untracked: true

image: java:openjdk-8-jre

Test05 Definition

test05:
stage: build
script:
- something that will generate folder public/test05

CS01 Definiition

cs01:
stage: build
script:
- something that will generate folder public/cs01

pages:
stage: deploy
script:
- echo ‘Nothing to do …’
artifacts:
paths:
- public
expire_in: 1 week
only:
- master

Goal is that both build stages generate different content in directory public that is later exposed via Gitlab pages. Everytime when I try it it’s just wiping my cs01 and test05 folders. Goal of that CI is that user can add another environment to this build stage (don’t know ran all of scripts in 1 stage as want parrarel run / some of them may fail).

Any advise how to use cache option so I will get my end goal ?