Guide 12 · Developer docs

Performance, caching, deployment and go-live

How Core dna caches pages, what makes a render fast, how code reaches a site and what stays behind, the go-live checklist, and running a site once it is live. For developers, leads and site operators who already build pages in a theme repository.

L2–L3
Unit 03 · The deployment model

Git-based deploy

A push to a branch is a deploy to every environment connected to that branch. What the platform does with the push, how branches map to environments, the Deployments list, and how to see which commit is live.

Who this is for. Developers and leads who ship code to a Core dna site. Afterwards you can predict exactly what a push changes on the server, read a deploy's result, and prove which commit a site is running.

There is no upload step and no deploy button. Each environment of a site can be connected to one repository and one branch, in the Version Control part of the environment's details (Repository, Branch), and a push to that branch deploys it. Knowing exactly what the deploy does explains most deploy surprises.

What a push does

  1. The repository host calls the platform with the repository and the branch of the push. Bitbucket and GitHub webhooks are both understood.
  2. The platform finds every environment connected to that repository and branch, adds an entry to each one's Deployments list with the status pending, and queues one deploy job for each. A push to a branch that no environment is connected to deploys nothing; the platform answers the webhook with "No sites setup for the repo … and branch …", which the repository host's webhook history shows.
  3. Each job brings the environment's folder to the branch. It fetches, switches the folder to the branch if it was on another one, and resets it hard to the branch as it stands on the remote at that moment. Every file git tracks becomes what the branch says, whatever was on the server before (FTP and tracked files). Files git does not track are left alone.
  4. It clears the caches of every environment that shares the folder: the stored pages and their CDN copies, the compiled templates and the CDN's copies of theme files (what a deploy clears).
  5. It sets the entry's status to success or failed.

The jobs run on the platform's background queue, so a deploy takes effect shortly after the push, not at the moment of it, and later when the queue is busy. Because the job takes the branch as it is when the job runs, two pushes close together can both deploy the later commit. Nothing is built on the server: what is committed is what is served (Build before you push).

Branches and environments

Which branch feeds which environment is part of each environment's configuration. A typical site:

BranchEnvironmentHostname
masterProduction, the site's primary environmentwww.example.com
stagingStagingstaging.example.com
Feature branchesNoneReviewed through pull requests, then merged into staging

Two consequences follow. Merging into master is releasing to production: there is no further gate. And because the environments of a site share one database, staging shows production's content running staging's code (Environments).

The Deployments list

Each environment in the admin has a Deployments list, newest first, with the columns Created, Status, Repository, Branch, Commit, Author and Message. The git output of the deploy is not shown there. When a change is not live, it is the first place to look:

  • No entry for the push: the branch or the repository is not the one this environment is connected to, or the webhook did not reach the platform. The repository host's webhook history shows the request and the platform's answer.
  • An entry still pending: the job has not run yet, or did not finish. Wait for the queue; if it stays pending, ask Core dna support to look at the job.
  • An entry marked failed: the deploy did not complete, usually because the repository could not be fetched. Ask Core dna support for the job's output; the change is not live.
  • An entry marked success, and the change is still not visible: the change was not in the commit (an unbuilt bundle is the classic case), or a browser or CDN is showing an old copy (is this copy stale).

Seeing which commit is live

$_currentSite->getLastVcsHash() returns the first seven characters of the commit of the current environment's newest Deployments entry, and getVcsBranch() the branch the environment is connected to. Use the hash as the version on asset URLs, so that every deploy makes browsers fetch the new files, and print it where you can read it:

Template code
<meta name="release" content="{$_currentSite->getVcsBranch()|escape}@{$_currentSite->getLastVcsHash()}">
<link rel="stylesheet" href="/dist/app.css?v={$_currentSite->getLastVcsHash()}">
<meta name="release" content="{{ _currentSite.getVcsBranch()|e }}@{{ _currentSite.getLastVcsHash() }}">
<link rel="stylesheet" href="/dist/app.css?v={{ _currentSite.getLastVcsHash() }}">

Then one command answers "is my commit live?" without signing in:

Shell
curl -s https://www.example.com/ | grep -o '<meta name="release"[^>]*>'
git log -1 --format=%h origin/master

Two cautions. The hash comes from the newest entry whatever its status, so a deploy that is still pending or has failed already reports its commit: check the entry's status before trusting the hash. And a page served from the cache shows the hash it was rendered with; a deploy clears the cache, so the first fresh render after it carries the new one. On a site without git deploys the method returns an empty string, so an asset URL needs a version of its own there (Cache-bust an asset URL).

Go deeper

Was this page helpful?

Your answer goes to the docs team.