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

server-side caching? #925

Closed
balupton opened this issue Jan 30, 2017 · 4 comments
Closed

server-side caching? #925

balupton opened this issue Jan 30, 2017 · 4 comments

Comments

@balupton
Copy link

balupton commented Jan 30, 2017

I'm considering using next.js for an application where we want to render markdown files.

However, rendering a markdown file + syntax highlighting + all the rest for each client request is quite intensive on the server, and on the client more so as each client has to load the markdown and syntax highlighting libraries to perform the operation.

Is there a way with next.js for the server to cache a request's render result somewhere, such that a future request can just serve the rendered HTML. This would move rendering of markdown and syntax highlighting to the server, but that seems like a good idea to me.

Or is such an approach antithetical to the react + next.js way?

@sergiodxa
Copy link
Contributor

There is already an example of server side rendering with cache in the repo:
https://github.com/zeit/next.js/tree/master/examples/ssr-caching

@balupton
Copy link
Author

balupton commented Jan 30, 2017

@sergiodxa okay cool - so does that avoid client-side rendering completely for pages that are inside the cache? as the risk I wish to avoid is having the dependencies of server-side rendered pages get included in client-side bundles, when they are not needed as the content is rendered server-side

@sergiodxa
Copy link
Contributor

No, what that it's going to do is that if the user access a page for the first time (or reload a page) the first time that page it's rendered in the server as usual, but after the first server render it's going to return the cache.

If the user transition to that page in the client, then it's always going to render in the client.

If you want to avoid that at all I think you can use a normal anchor tag to change pages to the only-server rendered page instead of using the Next.js Link component

@arunoda
Copy link
Contributor

arunoda commented Jan 30, 2017

Thanks @sergiodxa for answering the question.

@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants