Incremental builds not working as expected with Contentful

Hi, I’ve followed this guide to setting up incremental builds: Enable Gatsby Incremental Builds on Netlify

However, I’m not sure if there’s any additional action required after installing the plugin, configuring the netlify.toml file, and adjusting the build command.

Should I expect any change published in Contentful to trigger a new deployment? (I was actually expecting any save to trigger a new deployment because I am using the Contentful Preview API, but figured it’d be more straightforward to start with published posts.)

Our build command is currently prefaced with gatsby clean && .... I understand that’s not optimal, but should that have any impact on what the plugin stores?

What steps can I take to further debug the issue? There doesn’t seem to be a new deploy triggered in the Netlify dashboard, although I confirmed that manually building or re-running gatsby develop will pull in the new Contentful data as expected.

To follow-up on this, it seems like I would still need to trigger a rebuild somehow (either manually or using a hook),

But when I do this for a deploy preview of a branch that removes gatsby clean from the build command, I am noticing that it still rebuilds all the pages (including ones that have not changed) with each subsequent rebuild.

This happen even though it seems the plugin is working correctly:

2:48:24 PM: ┌────────────────────────────────────────────────────────┐
2:48:24 PM: │ 1. onPreBuild command from netlify-plugin-gatsby-cache │
2:48:24 PM: └────────────────────────────────────────────────────────┘
2:48:24 PM: ​
2:48:28 PM: Found a Gatsby cache. We’re about to go FAST. ⚡️
2:48:28 PM: ​
2:48:28 PM: (netlify-plugin-gatsby-cache onPreBuild completed in 3.4s)
2:48:28 PM: ​

hey there!

Our build command is currently prefaced with gatsby clean && ... . I understand that’s not optimal, but should that have any impact on what the plugin stores?

this will undo any incremental builds, caches, etc., so removing this is the right call. you can use the “Clear cache and deploy” option in Netlify to achieve the same outcome, but this should only be necessary in rare cases

Should I expect any change published in Contentful to trigger a new deployment?

to trigger new builds, you’ll need to create a Netlify build hook and then add it to Contentful’s webhook configuration

What steps can I take to further debug the issue?

are you setting the flag for incremental builds in your build command? it should be visible in the logs if it’s working

GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages

if not, you may need to update your netlify.toml or build settings to add it

when I do this for a deploy preview of a branch that removes gatsby clean from the build command, I am noticing that it still rebuilds all the pages (including ones that have not changed) with each subsequent rebuild.

if the flag is not set, this would be expected

if you make the above changes and you’re still having trouble, could you link to your build log so we could take a look?

thanks!

hey @jlengstorf thanks for the reply! yup i can confirm i followed all those steps and all the pages still seem to be regenerating according to the build log.

i know that build logs / ids aren’t particularly sensitive, but this is for my company’s work so i’d prefer to err on the side of caution. is there a way i could either PM you or Netlify support with the deploy details?

although i should note that our builds seem somewhat faster after implementing, i’m just not sure if i should expect pages with no changes to show as being “updated” in the build log:

11:12:34 AM: Updated page: {slug of post with no changes since last build}

there are a huge number of factors that can cause variability during builds, so I generally encourage looking at overall speed vs. specifics

in my experience, it took a few builds for deploy previews to consistently pick up the cache. I don’t know for sure if that was real or just my anecdotal experience, but I’d keep an eye on your next few deploy previews to see if it helps

for the build logs, it sounds like it’s working, so I’m not sure I need to see them anymore. if you continue to see issues, though, please hit us up again!