Early Hints for SaaS
Early Hints allows the browser to begin loading resources while the origin server is compiling the full response. This improves webpage’s loading speed for the end user. As a SaaS provider, you may prioritize speed for some of your custom hostnames. Using custom metadata, you can enable Early Hints per custom hostname.
Prerequisites
Before you can employ Early Hints for SaaS, you need to create a custom hostname. Review Get Started with Cloudflare for SaaS if you have not already done so.
Enable Early Hints per custom hostname via the API
Locate your zone ID, available in the Cloudflare dashboard.
Locate your Authentication Key by selecting My Profile > API tokens > Global API Key.
If you would like to enable Early Hints for a preexisting custom hostname, locate your custom hostname ID by making a
GET
request to the API:curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames" \-H "X-Auth-Email: {email}" \-H "X-Auth-Key: {key}" \-H "Content-Type: application/json"
If you are creating a new custom hostname, make an API call such as the example below, specifying "early_hints": "on"
:
curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames" \ -H "X-Auth-Email: {email}" \ -H "X-Auth-Key: {key}" \ -H "Content-Type: application/json" \ --data '{"hostname":"{your_custom_hostname}"}, "ssl”:{"wildcard": "true", "early_hints": "on"}}'
- For an existing custom hostname, an API call such as the example below, specifying
"early_hints": "on"
:$ curl -sXPATCH \"https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames/{hostname_id}" \-H "X-Auth-Email: {email}" \-H "X-Auth-Key: {key}" \-H "Content-Type: application/json" \--data '{"ssl": {"wildcard":"true","early_hints": "on"}}'