Cloudflare Docs
Pages
Edit this page on GitHub
Set theme to dark (⇧+D)

Early Hints

Early Hints help the browser to load webpages faster. Early Hints is enabled automatically on all pages.dev domains and custom domains.

Early Hints automatically caches any preload and preconnect type 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 _headers file

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:

_headers
/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.

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:

  • href
  • as
  • rel (preload or preconnect)

<link> elements which contain any other additional attributes (for example, fetchpriority, crossorigin or 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 _headers file.

/blog/index.html
<html>
<head>
<link rel="preload" href="/style.css" as="style" />
<link rel="stylesheet" href="/style.css" />
</head>
</html>

Remove any automatically generated Link headers by adding the following to your _headers file:

_headers
/*
! Link