Caches not helping on pipelines

Brian Duffey
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 9, 2025

We have a nextjs project that we have added the recommended cache definition to:

```

definitions:
  caches:
    nextcache: apps/rc-next/.next/cache
```
However, this doesn't seem to help much.  Basically, when there is no cache, it has no help (as expected) and will upload the cache after successful completion of the step.  Every time after that (for up to a week), it will reuse the existing cache, but the builds take longer and longer as the actual code further diverges from the original cache.
Adding in the keys would invalidate the cache every time meaning we'd never get any benefit.  What there needs to be is a way to always use the existing cache, BUT then upload the new cache if certain files have changed (or every time).  However, this does not seem to be possible even though it was requested back in 2018.
Is this accurate?  Is there any other way for us to get the benefit of caching more than once a week?

1 answer

0 votes
Sahir Maharaj
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2025

Hello @Brian Duffey

From my experience, caching in Bitbucket Pipelines can be tricky when dealing with evolving project states like diverging codebases.

While the current cache configuration saves time on repeat builds, it can degrade as code diverges. To address this, consider using cache keys that regenerate selectively based on specific file changes or build conditions.

Unfortunately, Bitbucket doesn’t currently support automatic updates to cache without invalidating it, as you mentioned.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events