-
Notifications
You must be signed in to change notification settings - Fork 196
Cache isn’t available to deploy previews #480
Comments
@ehmicky any thoughts on this one? |
Nevermind, I looked at jlengstorf/netlify-plugin-gatsby-cache#22 and I see that it's particular to deploy preview builds. |
I remember some discussions about caching in deploy previews having non-intuitive behavior at times (outside of Build plugins or the cache utility). If I remember, this discussion was with @fool, but I am not completely sure. @fool Are you aware of anything specific about caching in deploy previews? |
the issue I keep raising is this one: https://github.com/netlify/buildbot/issues/575 ...which is only about the FIRST build of any PR. Subsequent builds seem to me to have (correct) cache, and I think Support would have heard about it if the cache was never available to subsequent PR builds. |
Thanks for pointing this out @fool. |
I did some testing on this, and it's only impacting caching within Netlify Build - additional node modules, for instance, are cached successfully in deploy preview builds. Also verified that it's not an issue for other non-master builds (ie branch builds). Once the file is cached successfully (for example during a branch build), it's can be loaded successfully in a deploy preview build. So, the problem seems to be with saving. I'm not really sure how the context might be interacting with caching for Netlify Build alone. |
According to the Debug Cache Plugin, my cache is not being shared between builds on a deploy branch. See spotlightpa/poor-richard#104. (Parcel, like Gatsby, use the .cache directory.) |
I believe this is happening on the API side - @erezrokah pointed me in the right direction. We track a list of branches we've got a cache for. If some build of a branch (either triggered by a branch deploy or a deploy preview) has an existing cache, we use it. Otherwise we fall back to the cache for the master branch. However, we only update the list of "branches with an existing cache" on branch deploys. So, when I saw the The In the deploy previews here you can see that |
If the cache doesn't currently work in the deploy preview, can we document that somewhere in the site or in the READMEs? It's totally fine if that's the way it works, but I just spent my whole day trying to debug why the build cache wasn't working just to find out it was because the cache doesn't work in the deploy preview 😅 |
What I'm currently not understanding is why we're able to set a digest for saving but not restoring. How does netlify even determine which cache to use? In all CI providers with caching I'm familiar with you have a single "cache"-task with a digest that can contain strings and files. The CI provider then uses this for saving and restoring. I should be able to do the same (Azure cache, CircleCI cache, GitHub cache) The reason why you can usually hard code strings is if you have cache "evolutions" where you simply want to avoid cache sharing for one reason or another. The you go from Right now it's not apparent how netlify is determining if it should re-use a cache or not. By making this behavior configurable or at least transparent we'd probably be able to figure out why netlify is sometimes not caching deploy previews. On a personal note: Caching for deploy previews is way more important for OSS packages than it is for branch deploys. The number of deploys we get from deploy previews is easily a magnitude bigger than that of production deploys. It's also the situation where you want the lowest response time between push and ready deploy. |
Netlify Support here 👋🏻 Exciting update: this has been fixed 🎉 Check out the community post for more details: https://community.netlify.com/t/build-cache-is-now-updated-in-deploy-preview-builds/26344 |
I am creating and caching a file and getting confirmation from the utils that it was cached, but it's not there on subsequent pushes to that PR
this log shows a cache miss, despite confirmation that the cache was created in the previous deploy (you can see the confirmation again, as well as a quick read of the file contents to make sure they're actually there, in the bottom of this log)
https://app.netlify.com/sites/modest-murdock-9912c4/deploys/5eae49da1063950007a54613
source code: https://github.com/jlengstorf/netlify-plugin-applitools-demo/tree/feat/netlify-plugin-high-five/netlify-plugin-en-corg-agement
The text was updated successfully, but these errors were encountered: