While CDN layers have typically provided a remarkable boost of performance, that has not come without a cost.
In particular, getting the right caching configuration can be quite tricky. Configuring headers, caching behavior, and overrides are not only difficult but can result in stale content being delivered to your end users.
Now gets around these problems with its simple immutable model. In the following example, we make a static deployment that gets automatically cached. When we run now alias, however, to assign a domain name to my deployment, we automatically purge the CDN cache.
`now alias` will purge the cache for any alias or domain so there's never stale content being served
The very website you are reading now is served from the edge. It's powered by React-based server-rendering for both static and dynamic pages.
Since it's a dynamic deployment, we configured the Cache-Control headers appropriately. As most of the content varies based on the logged-in state of the user, we don't send caching headers when the authentication cookie is set.
In order to bypass the cache, we have introduced a generic cookie you can set: _now_no_cache=1 (read more about this in the documentation. Our CDN layer will hit origin every time if it finds it in the Cookie header.
When adding a domain to any paid plan, the Now CDN will be automatically enabled for the domain going forward.
You can get a domain with us or you can add an externally registered domain to your account using now domains add [your domain].
If you have a domain already associated with your ZEIT account, you can enable the CDN using either the ZEIT website or Now CLI.
To enable the CDN from our website you will need to be logged in. Head to the dashboard of your account or the team that holds the domain you want to enable the CDN for, then head to the 'Domains' section of your dashboard. From here, you'll be able to simply click a checkbox to activate the CDN for any domain you want!
Enabling the CDN via zeit.co
Enabling the CDN for pre-existing domains on your account with the Now CLI is as simple as one command:
now domains add [your domain] --cdn
You can also use the --no-cdn flag to disable the CDN when adding a new domain or on existing domains.
Until today, your content could be cached at the edge only by our origin clusters in California and Brussels. Starting today, we are seamlessly expanding this to 150+ locations throughout the world, with the same ease and simplicity you are used to.
We think this is an important step in the evolution of our platform. This kind of seamless, zero-downtime platform upgrade embodies the core mission of our company: that you should be able to deploy without being hindered by servers or complicated administration.
With this in mind, we will continue to expand our network throughout the rest of 2018. We look forward to sharing more good news with you soon.