Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example using ESI cache (with React ESI) #6225

Merged
merged 6 commits into from
Feb 22, 2019

Conversation

dunglas
Copy link
Contributor

@dunglas dunglas commented Feb 8, 2019

React ESI is a brand new cache library for vanilla React and Next.js applications, that can make highly dynamic applications as fast as static sites by leveraging the open Edge Server Include specification.

https://github.com/dunglas/react-esi

Because this spec is widespread, React ESI natively supports most of the well-known cloud cache providers including Cloudflare Workers, Akamai and Fastly. Of course, React ESI also supports the open source Varnish cache server that you can use in your own infrastructure for free (configuration provided).

This PR shows how to integrate React ESI with Next.js.

},
"scripts": {
"dev": "nodemon --exec babel-node src/server.js localhost 3000",
"build": "babel src -d dist && next build dist",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed: babel src -d dist &&

Copy link
Member

@timneutkens timneutkens Feb 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to run babel over the src directory 🤔 You'd be triple parsing and compiling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that React ESI needs to be able to serve the components (src/components) directly. Is it possible to reuse the ones compiled by Next?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, that makes it indeed harder, all components are put into a single bundle per page and are not available to be required outside of the bundle, so that is an issue.

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a bunch of feedback 🙏 Looks like a nice solution 👍

@dunglas
Copy link
Contributor Author

dunglas commented Feb 8, 2019

Thank you very much for the feedback @timneutkens. I simplified the example.
Regarding the compilation, I fear it will require to patch the Next build process. Do you think this example is good enough as is in the meantime?

@dunglas
Copy link
Contributor Author

dunglas commented Feb 12, 2019

As far as I understand, the build failure is unrelated to this PR.

@dunglas
Copy link
Contributor Author

dunglas commented Feb 19, 2019

Hi @timneutkens, is this PR ready to be merged on your side? Thanks!

@timneutkens
Copy link
Member

@dunglas could you send me a DM on twitter.com/timneutkens / https://spectrum.chat/users/timneutkens

@timneutkens timneutkens merged commit e0896e5 into vercel:canary Feb 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants