I’d love to know if Netlify Functions can be used for server side rendering.
This is what needs to happen:
Build
- Netlify runs the build command to generate both the server lamdba and the static files.
- Netlify uploads the server file (for example
/build/server.js
) to AWS lambda. - Netlify uploads static files found in a folder (for example,
/build/static/*
).
Runtime
- Netlify serves the static files when the
/static/*
URLs are accessed. Those files are cached by the CDN according tocache-control
headers. - Netlify servers the HTML generated by the
/build/server.js
lambda to any other URL. Those HTML responses are cached by the CDN according tocache-control
headers.
I took a look at the netlify.toml
and I saw you can configure redirects.
- Could those redirects be used to make Netlify serve HTMLs generated by the server lamba?
- If that’s the case, could those HTML responses be cached by the CDN?
- Is there any other way I’m not aware of to make this happen?