Is cache saved if jobs fails on timeout?

Hello,

I have a job that takes a long time to build a program.
Usually the build time get over the timeout limit for the job (whether it is the timeout of the runner, the project or the job).

However I planed to use the ccache to speed up repetitive compilation. Cache of ccache is strored in the cache of the job thanks to the use of the cache keywork. This works fine for jobs that complete before the timeout, on subsequent runs, ccache’s cache is used.

However, if the job fails because it reached the timeout, will the cache of the job still be saved or is everything lost? How to achieve this in .gitlab-ci.yml? For now, I used cache:when: always without being sure that it will help

Thanks