DEV Community

Cover image for Refresh Gatsby Content Without Restarting Development Server
Gregory Gaines
Gregory Gaines

Posted on • Originally published at gregorygaines.com

3 3

Refresh Gatsby Content Without Restarting Development Server

I can't count how many hours I've wasted staring at my terminal waiting for the Gatsby development server to restart after editing content. Luckily, Gatsby can expose an endpoint to refresh content without restarting the whole server.

Prerequisite

Enabling Refresh Endpoint

Add ENABLE_GATSBY_REFRESH_ENDPOINT=true to your development environment variables to enable the refresh endpoint. The endpoint exposes as http://localhost:8000/__refresh.

{"title": ".env.development"}
ENABLE_GATSBY_REFRESH_ENDPOINT=true
Enter fullscreen mode Exit fullscreen mode

Triggering Refresh Endpoint

Using postman, send an HTTP POST request to the http://localhost:8000/__refresh endpoint.

Much faster than a complete server restart.

Using the Terminal

The refresh endpoint can also be triggered using the terminal on Unix-based operating systems.

curl -X POST http://localhost:8000/__refresh
Enter fullscreen mode Exit fullscreen mode

Conclusion

The refresh feature is enabled by adding the ENABLE_GATSBY_REFRESH_ENDPOINT=true development environment variable. The endpoint is exposed as http://localhost:8000/__refresh and triggered by POST requests.

If you believe I've helped, consider signing up for my newsletter or supporting me.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay