Option To Keep public/ And .cache/ Folders

Did you use the search bar to find a category that would fit your needs?
Yes
As you write your post:
Is it possible to somehow keep public or .cache folders on builds? I know that netlify uses cached versions of node_modules so i think it should be possible. This would allow really quick build times for incremental builds. A website with a ton of pages doesnt need to rebuild every single thing for a small typo fix on 1 page. I use GatsbyJS on my website and the only headache that i think can prevent this is netlify doesn’t keep these 2 folders.

When using gatsby develop it becomes incredibly easy and almost instant changes because the rebuild is only applied to files that are changed. This is possible because the public and .cache folders are not deleted.

Briefly summarize the issues you have been experiencing.
Long build times on the smallest of changes on large sites.

Please provide a link to your live site hosted on Netlify
https://shoptitans.xyz

What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?
I am not sure if this can be troubleshooted as I did not find this option anywhere.

Do you have any other information that is relevant, such as links to docs, libraries, or other resources?

Hi,

First of thank you for bringing up this issue, i do believe that caching (at least) the .cache folder would decrease the build time by half, gatsby has an excellent built-in image manipulation and resizing system which is used largely on all gatsby project. On new build the build process has to generate all images from scratch on every build, having that cached would decrease build times by a lot. This is a major resource hog.

The good news is that the build-image is entirely open source and you can create a PR to fix it.
I’m not expert, but after having a look at the source I think this can be easily implemented. One major thing that needs to be addressed is .cache folder is always created and it is used when the build process is using python as a build environment so that needs to be addressed

The option would be to use the cache-me-outside repo on pre-build step and copy the .cache programatically. But this would mean that you need to manage the content of the .cache folder. This is clearly an option but it feels like a workaround and it might not be very useful when you have lots of files in .cache

The other option would be to just wait, it’s a known secret that @DavidWells is working on new build system. But i don’t know anything more about this. Because this is in development the build-image is getting less attention so it’s kinda like a Catch 22 situation at the moment.

That being said i would like to see this being implemented!

1 Like

hi to you both, i am moving this to the #netlify-platform:feedback-features-pricing section as this fits better there :slight_smile:

You can cache anything you’d like, but we won’t be able to help you debug in case it goes wrong. There is a gatsby-specific caching module here, though it has had bugs that caused hard-to-debug site building failures for someone in the past due to some bugs that the developer claims is fixed:

https://www.gatsbyjs.org/packages/gatsby-plugin-netlify-cache/

A more generic caching npm module that you can use from any framework is this one:

As I mentioned and must reiterate, we won’t be able to help you debug failures in using them in depth, but you are welcome to try them out as they do work for many customers.

1 Like

There’s a PR in the build-image repo which will help cache the .cache and public folders.
It maybe needs some more work and some :heart:

I believe this will halve the build time for the sites built with gatsby.
In the mean time gatsby-plugin-netlify-cache is viable alternative.

1 Like