Feature request: force skip requests to wordpress
Closed this issue · 6 comments
When you deal with a big project with at least 30-40 pages, that has some content that is coming from WP it becomes annoying to switch between branches/restart service because it causes regeneration and redownloading of all assets if there is a change of dependecies. It takes time, and even having a local version of WP does not help a lot since Gatsby starts to query everything again. It would be nice to have an option that will force the use of the current version of downloaded assets as well as content data that was already downloaded without even making a single query to a data source.
I know Gatsby focused more and more on speeding up the production build time, however, development environment builds on local machine becomes time-consuming as well, especially when it comes to PR reviews or edits in gatsby-node.js.
Hi @lnikell , this is a great request! I've added 2 API's that are meant to help in (almost) this situation. There is options.develop.hardCacheData
and options.develop.hardCacheMediaFiles
. The media file hard-cache will work across sources, however the data hard cache will not. It would be possible to hard cache in a directory created from options.url
though, so that could easily enable the functionality you're looking for :)
Currently we're working on shipping a stable release of this plugin and we're heavily focused on getting Preview to work as seamlessly and reliably as possible so we won't be prioritizing this now, but could in the future. If you're interested in opening a PR for this, you would want to change this line https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/blob/master/plugin/src/utils/cache.js#L27 so that the cache directory includes a hash of the WP url.
Hi, @TylerBarnes thank you for the feedback. That's definitely will be very useful in the future. Actually can't wait to see it working :) Because Dev experience on any real WP project is not great. Please don't get me wrong.
I've checked options.develop.hardCacheMediaFiles
it creates wordpress-cache indeed, but if I get you right it does not work at this moment, so it does not affect build time, etc. I will try to debug a bit the part of the code you sent, to understand better how does it work.
Ahh, dangit! definitely a regression. I'll fix this soon and add a test for it. I see that it's hard caching the files but not properly restoring them for some reason. And thank you for the feedback too, we need real-world honest feedback!
@lnikell , hardCacheMediaFiles
is working on latest! There was some missing logic with fetching images where when we couldn't identify what the MediaItem node was they weren't being hard cached.
thank you @TylerBarnes, already added it to a couple of projects, very curious will it improve the experience or no :)
Closing this as hardCacheMediaFiles
and hardCacheData
are working on latest 👍