List of excluded files that should not be served
The time in seconds that the statically rendered response is considered valid. Must be a positive number. If it's not specified the rendered response never expires.
The path to a statically rendered loading page to be served when falling back to compute. By
specifying both loadingPage
and onNotFound
, when a request cannot be fulfilled with a static asset,
Edgio will instantly serve a loading page while computing a server-side rendered result for future requests.
This ensures that all requests will have a low time-to-first-byte (TTFB) and no user will need to
wait for SSR to finish before seeing something in their browser.
Example:
router.get('/products/:id', res => {
res.serveStatic('dist/products/:id.html', {
onNotFound: () => res.renderWithApp(), // fall back to server-side rendering
loadingPage: 'dist/products/loading.html' // show the loading page while SSR is in progress
})
})
Note that it's up to your front-end code to fetch the data to render the full page when the loading page is served.
Frameworks like Next.js, for example, do this automatically when you use getStaticPaths
with fallback: true
.
A function to run when no static asset exists at the specified path. Use this option to perform server-side rendering for URLs that are not statically rendered at build-time.
Example:
router.get('/products/:id', res => {
res.serveStatic('dist/products/:id.html', {
onNotFound: () => res.renderWithApp() // fall back to server-side rendering
})
})
Because SSR can often be slow, we recommend using this option in conjunction with
loadingPage
so that users do not have to wait for SSR to finish before seeing something in their browser.
When true, assets are served from a bucket/prefix that remains available across all builds on a given environment.
Sets the status code for the response. If not specified, the status code will be 200.
Sets the status code for the response. If not specified, the status message will be "OK".
Generated using TypeDoc
Options for the
serveStatic
method.