# Publishing

URL: https://docs.ablyft.com/developers/installation/publishing/

> How changes in ABlyft reach your visitors, and how to check the state of your snippet.



Your website loads a snippet file from the ABlyft CDN. That file contains the current configuration of your project:
running experiments, variations, pages, audiences, goals and settings. **Publishing** means creating a new version of
this file and uploading it to the CDN. Because the URL stays the same, you never have to change the code on your website.

## Publishing is automatic

You do not have to publish manually. ABlyft publishes your project when something relevant changes, for example when you:

* create, edit, start or pause experiments and variations,
* change pages, audiences, goals or environments (including attaching and detaching them),
* change snippet, project, prerequisite or data protection settings,
* delete or restore these items.

Changes that only touch internal timestamps do not trigger a publication. The first snippet is created when you create the
project.

## What happens during a publication

1. The **Snippet revision** of the project increases by one and **Last published** is set to the current time.
2. ABlyft generates the snippet and uploads it to the CDN. If you use [sub-snippets](https://docs.ablyft.com/developers/installation/environments/#sub-snippets),
   they are uploaded too.
3. Your [publication webhooks](https://docs.ablyft.com/developers/installation/snippet-settings/#publication-webhooks) are called, if you have configured some.

This runs in the background, a few moments after you save.

## The Publishing indicator

While a publication is in progress, the top bar shows a **Publishing …** button with a countdown in seconds. Hover over it
to see "The snippet is being updated (uploading to CDN)".

The countdown is as long as the **Cache expiration (ttl)** of your snippet. It shows how long it can take until visitors
whose browser cached the old snippet receive the new one, see
[Cache expiration](https://docs.ablyft.com/developers/installation/snippet-settings/#cache-expiration-ttl). While
[debug mode](https://docs.ablyft.com/developers/debugging/preview-and-live-log/#debug-mode) is on, caching is off and no countdown is needed.

## Check the state of your snippet

On **Settings → Snippet** you find:

| Field                          | Meaning                                  |
| ------------------------------ | ---------------------------------------- |
| **Snippet revision**           | How often the project has been published |
| **Last published**             | Date and time of the last publication    |
| **Snippet size (before gzip)** | Size of the snippet file                 |
| **Sub-Snippets**               | The snippets of your environments        |

In the browser, `ablyft.get('data')` returns the `revision` of the snippet that the visitor actually loaded, see
[`ablyft.get()`](https://docs.ablyft.com/developers/reference/javascript-api/get/#data). If it is lower than the revision in ABlyft, the browser
still uses a cached version.

## Publish manually: Test webhooks

To publish without changing anything, for example to test a webhook endpoint:

1. Go to **Settings → Project Settings** and find the section for publication webhooks.
2. Click **Test webhooks**.
3. Confirm with **Yes, publish now**.

ABlyft then publishes the project as if it was saved, regenerates all snippets and calls your webhooks. The fields that
a webhook receives (`team_id`, `project_id`, `snippet_revision`, `snippet_script`) are described in
[Snippet settings](https://docs.ablyft.com/developers/installation/snippet-settings/#publication-webhooks).

## Troubleshooting

* **A change is not visible yet.** Wait for the **Publishing …** countdown to end and for the cache expiration time. Then
  reload the page. See [Common issues](https://docs.ablyft.com/developers/debugging/common-issues/).
* **The revision in the browser is older than in ABlyft.** The browser or a proxy cached the snippet. Reload the page, or
  check whether you load the snippet through a service that caches files for longer.

## Next steps

- [Snippet settings](https://docs.ablyft.com/developers/installation/snippet-settings/): Cache expiration, anti-flicker, debug mode and webhooks.
- [Debugging](https://docs.ablyft.com/developers/debugging/): Verify what the visitor receives.

