Edgio

Purging Cached Content

Purge cached content to force the CDN to request a new version of that content from an origin server or Cloud Functions. This ensures that the latest version of that content is delivered to your clients.
Purging does not delete content from the origin server. A file management tool (e.g., SFTP or rsync) may be used to delete content from an origin server.
Purge by hostname, relative path, surrogate key, or all cached content using the:
By default, deploying to Edgio preserves an environment’s cached content. Learn more.

Hostname

You may purge cached content by the request URL’s hostname. Choose between either of the following options:
  • Purging all cached content for that hostname. Verify that the Purge all entries option is selected and then select the desired hostname from the Hostname option.
    Purge by hostname
  • Purging requests for that hostname and a specific relative path. Select the Purge by path option and then select the desired hostname from the Hostname option.
    Purge by hostname and relative path

Relative Path

You may specify a relative path that identifies the set of cached responses that will be purged. This relative path starts directly after the hostname.
Use an * to represent zero or more characters.
Example:
This example assumes that you need to purge the following content:
https://cdn.example.com/sports/basketball/marchtournament.html
Purge the above URL by specifying the following relative path:
/sports/basketball/marchtournament.html
Alternatively, you can use an * to recursively purge a directory. The following relative path pattern recursively purges all content from the /sports directory including marchtournament.html:
/sports/*

Surrogate Key

You may purge cached content by surrogate key (aka cache tag). A surrogate key is a label that you may apply to cached responses. Purging by surrogate key allows you to purge related content across your entire site.
Improve performance and reduce the load on your web servers by only purging targetted content through the use of surrogate keys.

Tagging Cached Content

Apply a surrogate key by setting the Surrogate-Key response header.
Syntax: Surrogate-Key: <TAG1> <TAG2> <TAG3>
Example:
For example, the following response header applies three surrogate keys to the cached response. Purging any of those three surrogate keys will purge all cached responses tagged with that surrogate key.
Surrogate-Key: sports basketball march-tournament
View a sample configuration.

Edgio Console

Use the Edgio Console to purge cached content within a specific environment.
To purge content
  1. Load the Caching page.
    1. From the Edgio Console, select the desired private space or organization.
    2. Select the desired property.
    3. From the left-hand pane, select the desired environment from under the Environments section.
    4. From the left-hand pane, select Caching.
  2. From the Cache Purge History section, click Purge the Cache.
    purge_the_cache_button
  3. Purge:
    • All Cached Content: Select Purge all entries.
    • By Path: Select Purge by path. Specify each desired relative path on a separate line.
    • By Hostname: Select Purge all entries and then select the desired hostname from the Hostname option.
    • By Hostname for a Specific Path: Select Purge by path, specify the desired relative path(s), and then select the desired hostname from the Hostname option.
    • By Surrogate Key: Select Purge by surrogate key. Specify each desired surrogate key on a separate line.
  4. Click Purge Cache.
  5. When prompted, click Purge to confirm that your content will be purged.

Edgio CLI

Purge cached content through the Edgio CLI by passing the cache-clear argument. You may purge:
  • All content: Exclude the --path and --surrogate-key options.
  • By relative path: Pass the --path option. You may use an * to represent zero or more characters.
  • By surrogate key: Pass the --surrogate-key option. Learn more about surrogate keys.
Example:
Run the following command to purge the basketball surrogate key from the production environment from the my-videos property:
Bash
1edgio cache-clear --organization=my-organization --property=my-videos --environment=production --surrogate-key=basketball

REST API

Purge cached content through the Edgio REST API through the Purge Cache endpoint. You may purge:
  • All content: Set the purge_type property to all_entries.
  • By relative path: Set the purge_type property to path. Pass the desired relative paths through the values array of strings. You may use an * to represent zero or more characters.
  • By surrogate key: Set the purge_type property to surrogate_key. Pass the desired surrogate keys through the values array of strings. Learn more about surrogate keys.
  • By hostname: Set the hostname property to the desired hostname. Purging by hostname is compatible with the purge_type property set to either all_entries or path.

Deployments

By default, cached content is preserved when you deploy a new version of your site. Override this behavior when deploying changes by marking the Purge the cache after deployment setting on the Deploy Changes popup. The default state for this option is determined by the Caching page’s Automatically purge the cache on deployments option.
Deploy Changes - Purge the cache after deployment
While preserving the cache between deployments can greatly reduce the load on your origin following a deployment, it can also lead to inconsistent behavior if the new version of your browser code receives an old, incompatible API response from the cache. If you plan on preserving cache content between deployments, then we recommend adding an API version number to your URL scheme to ensure that breaking changes to your API don’t affect your website’s functionality when old responses are served from the cache.

Automated Purging

Automate cache purging through NPM scripts and GitHub actions.

NPM Scripts

Here is an example script you can add to your package.json to handle cache clearing for each environment. You can also configure scripts to clear by surrogate key, path, or group (As defined in Edgio Console)
These scripts assume that you have created environments called “production”, “staging”, and “development and you have created a deploy key for your site and added it as a secret in your repo called “edgio_deploy_token”.
JavaScript
1"scripts": {
2 ...
3 "clearcache:dev": "edgio cache-clear --organization=my-organization --property=myEdgioApp --environment=development --token=$edgio_deploy_token",
4 "clearcache:stage": "edgio cache-clear --organization=my-organization --property=myEdgioApp --environment=staging --token=$edgio_deploy_token",
5 "clearcache:prod": "edgio cache-clear --organization=my-organization --property=myEdgioApp --environment=production --token=$edgio_deploy_token",
6 "clearcache:prod:pdps": "edgio cache-clear --organization=my-organization --property=myEdgioApp --environment=production --surrogate-key=pdp --token=$edgio_deploy_token",
7 "clearcache:prod:plps": "edgio cache-clear --organization=my-organization --property=myEdgioApp --environment=production --surrogate-key=plp --token=$edgio_deploy_token",
8 ...
9 },

GitHub Actions

Here is an example GitHub action that clears the cache at a scheduled time using the jobs defined in your package.json
YAML
1# Add this file to your project at .github/workflows/clear-cache.yml
2#
3# This GitHub action clears the sites PRODUCTION cache at 09:15AM UTC every day.
4#
5# The schedule syntax is standard cron syntax
6# minute hour day-of-month month day-of-week
7# * * * * *
8#
9# 1.) This example depends on a script being defined in your package.json called clearcache:prod
10#
11# In order for this action to clear your cache, you must create a deploy token from the site settings page
12# in https://edgio.app and configure it as a secret called "edgio_deploy_token" in your repo on GitHub.
13
14name: Clear PRODUCTION cache at 5am
15on:
16 schedule:
17 - cron: '15 9 * * *'
18jobs:
19 clear-the-cache:
20 runs-on: ubuntu-latest
21 steps:
22 - name: Extract branch name
23 shell: bash
24 run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_ENV
25 - uses: actions/checkout@v1
26 - uses: actions/setup-node@v1
27 with:
28 node-version: 14
29 registry-url: https://npm-proxy.fury.io/layer0/
30 - name: Cache node modules
31 uses: actions/cache@v1
32 env:
33 cache-name: cache-node-modules
34 with:
35 path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
36 key: ${{ runner.os }}-build-${{ env.cache-name }}-$&lcub;&lcub; hashFiles&lpar;&apos;&midast;&midast;&sol;package-lock&period;json&apos;&rpar; &rcub;&rcub;
37 restore-keys: |
38 ${{ runner.os }}-build-${{ env.cache-name }}-
39 ${{ runner.os }}-build-
40 ${{ runner.os }}-
41 - run: npm ci
42 - name: Clear cache in production
43 run: npm run clearcache:prod
44 env:
45 edgio_deploy_token: ${{secrets.edgio_deploy_token}}