Deployment of Static Sites
Connector configuration
In purely static contexts, API caching can lead to a misalignment between the data inserted on the Discovery platform and those
of the site, caused by the presence of data in the cache that has not yet been invalidated. It is therefore a good idea to configure the connector to avoid the API cache
always request the latest data, as the performance drop is limited to the build process. To do this you need to enter in the setup
the disableCache: true
parameter.
In hybrid contexts, with some static pages and others generated server-side, it is important to avoid this configuration and instead disable the cache
at the single call level via the getPage()
and getContent()
method options.
Deployment via Webhooks
If the site must be distributed via services such as Vercel, Netlify or equivalent, which support webhooks, it is possible to configure the webhooks to be invoked in the event of Deploy on the property detail page. To obtain the webhook URL, check the documentation of the third-party service. Once the URL has been obtained, it must be inserted in the property panel under Webhooks > Deploy Webhook URL/Method.
To test the configuration, click on the Deploy button inside the property and check on the third-party service console that the build has been started.
Deployment via AWS S3
Discovery CMS supports both dynamic and static sites. If no server-side page rendering is needed, it is possible to choose deployment as static HTML, with the advantage of high performance at very low costs, as the site can be fully hosted, for example, on an AWS S3 bucket and accelerated with AWS CloudFront.
If your site consists of a large number of pages, such as an e-commerce or news site, Discovery CMS supports the incremental deployment: once the initial site has been created with a page generated for each product/news item (even thousands of pages, which could take hours to compile), in subsequent deployments incremental generation is possible for the only pages that have been changed. For example, if 100 out of 10,000 products are updated, Discovery CMS can only generate pages for the 100 updated products.
This type of deployment must be requested during the setup phase of the Discovery platform requesting "RIF_CMS_DEPLOY_S3_SETUP" to the Reply Professional Services.
Property configuration
It is possible to decide the type of deployment, static or dynamic, for each property by accessing the settings page. Furthermore, it is necessary to create a deployment script and connect, again via the settings, this script to the property. Reply can offer support for creating the deployment script.
The script will receive a LAST_DEPLOY_TIMESTAMP
environment variable set by the Discovery CMS. This variable is used by the NextJS application to query the CMS API and request only content that has changed since the last deployment.
Script example:
#!bin/sh
npm run export --prefix /Projects/HeadlessCMS/headless-cms/discovery-frontend/mywebsite && aws s3 sync /Projects/HeadlessCMS/headless-cms/discovery-frontend/monorepo/sites/media-library-cms-static/out /. s3://media-library-cms-static && aws cloudfront create-invalidation --distribution-id EDFDVBD6EXAMPLE --paths "/*"
The script above:
- export the static site locally
- uploads it to the S3 bucket
- invalidates the CloudFront distribution that has the S3 bucket as its origin
Multilingual static sites
TODO