Early Hints help the browser to load webpages faster. Early Hints is enabled automatically on all
pages.dev domains. To enable Early Hints for your custom domains:
- Log in to Cloudflare dashboard and select your account and domain.
- Go to Speed > Optimization.
- Turn on the Early Hints toggle.
Early Hints automatically caches any
Link headers to send as Early Hints to the browser. The hints are sent to the browser before the full response is prepared, and the browser can figure out how to load the webpage faster for the end user. There are two ways to create these
Link headers in Pages:
Configure Early Hints
Early Hints can be created with either of the two methods detailed below.
1. Configure your
Create custom headers using the
_headers file. If you include a particular stylesheet on your
/blog/ section of your website, you would create the following rule:
/blog/*Link: </styles.css>; rel=preload; as=style
Pages will attach this
Link: </styles.css>; rel=preload; as=stylesheet header. Early Hints will then emit this header as an Early Hint once cached.
Link header generation
In order to make the authoring experience easier, Pages also automatically generates
Link headers from any
<link> HTML elements with any of the following attributes:
<link> elements which contain any other additional attributes (for example,
data-do-not-generate-a-link-header) will not be used to generate
Link headers in order to prevent accidentally losing any custom prioritization logic that would otherwise be dropped as an Early Hint.
This allows you to directly create Early Hints as you are writing your document, without needing to alternate between your HTML and
<html><head><link rel="preload" href="/style.css" as="style" /><link rel="stylesheet" href="/style.css" /></head></html>
Link header generation Automatic
Remove any automatically generated
Link headers by adding the following to your