Back to home

Varnish cache: control cache using HTTP

We offer an HTTP API for the autonomous management of Varnish cache. This allows you to invalidate individual pages or entire areas or to update individual pages in the background.

To protect the API from misuse, access via ACL is restricted to certain IP addresses only.

If this API does not work for you, please contact our support team (support@nine.ch). We would be pleased to work with you to tailor the API to your requirements.

Three basic operations are described below. However, your individual set-up may deviate from this.

Purge

The purge command enables individual pages located in the cache to be invalidated. The next time this page is accessed, it will be loaded from the back-end and stored in the cache.

The following command invalidates the URL in the cache:

curl -X PURGE -D - http://www.nine.ch/site/to/purge.html

Ban

The ban command enables you to invalidate entire areas in the cache as opposed to individual pages only. Both the host name and the path can be defined via regular expression.

The following command invalidates all pages under /images/ at www.nine.ch:

curl -X BAN \
  -H 'X-Ban-Host: www.nine.ch' \
  -H 'X-Ban-Url: /images/.*' \
  -D - http://127.0.0.1/

Refresh

The refresh command enables individual pages located in the cache to be updated in the background. All other clients will continue to be supplied with the old content until the update in the cache is complete.

The following command updates the URL in the cache:

curl -X REFRESH -D - http://www.nine.ch/site/to/purge.html

Didn't find what you were looking for?

Contact our support:

+41 44 637 40 40 Support Portal support@nine.ch