Now CDN enabled domains are automatically fronted by over 150 locations, allowing you to immediately optimize all of your Now deployments with a single command.
To use the CDN, you must be on a paid plan. Any new domain or
*.now.sh alias created under a paid plan will automatically have the CDN enabled.
For any existing domains, added before the CDN was released, or domains that have had the CDN disabled, you can enable the CDN with the Now CLI by running the following command:
You can also enable or disable the CDN for a domain by heading to the dashboard of your account or the team that holds the domain you want to enable the CDN for, then heading to the 'Domains' section. From here, you'll be able to simply click a checkbox to activate the CDN for any domain you want.
If your domain isn't using zeit.world DNS yet, you first need to migrate to zeit.world.
The Cache-Control header can include a number of directives, separated by comma.
Caching directives break down the caching controls into three categories:
When aliasing to any Now CDN enabled domain or
now.sh alias, we automatically purge the cache so that no stale content is ever delivered.
max-age=<seconds>indicates when response is to be considered stale. It is represented in seconds since it was downloaded from the origin server.
s-maxage=<seconds>indicates when the response is to be considered stale by shared caches. It takes precedence over
no-cacheindicates the response MUST NOT be used to satisfy a subsequent request without successful validation on the origin server.
must-revalidateindicates that once it has become stale, a cache (client or proxy) MUST revalidate the content before using the cached entry.
proxy-revalidatehas the same definition as the
must-revalidatedirective, except that it only applies to shared caches.
stale-while-revalidate=<seconds>indicates that caches MAY serve the response in which it appears after it becomes stale, up to the indicated number of seconds since the object expired.
stale-if-error=<seconds>indicates that when an error is encountered, a cached stale response may be used to satisfy the request, regardless of other freshness information.
no-transformindicates that an intermediary proxy and/or cache must not transform the payload.
immutableindicates to clients that the response body will not change over time.
We recommend leveraging shared caches over client caches. For example,
Cache-Control: max-age=0, s-maxage=86400 may be used to instruct shared caches to cache for 86400 seconds and clients to not cache. Similarly,
Cache-Control: max-age=60, s-maxage=86400 instructs shared caches to cache for 86400 seconds and clients to cache for 60 seconds.
Cache-Control response header is present, the Now routing layer adds
Cache-Control: s-maxage=0, to ensure that no shared caches will cache content that wasn't explicitly marked as cacheable.
Any request where the client appends an
Pragma header will bypass the cache.
Currently, the Now CDN can only be enabled for single level of subdomains. This means that, for example,
*.zeit.university will be fronted by the CDN, while
*.dev.zeit.university will be routed directly to our origin locations.
You can disable the CDN for a given domain by running the following command: