---
- job:
    name: clear-cdn-cache
    display-name: Clear CDN cache
    project-type: freestyle
    description: >
      Clears the CDN cache for the 10 most popular pages on GOV.UK.
    properties:
      - build-discarder:
          num-to-keep: 30
    builders:
      - shell: |
          #!/usr/bin/env bash

          set -ex

          declare -a hostnames=(
            "<%= @website_root_url -%>"
            "<%= @assets_root_url -%>"
          )

          # 10 most popular pages based on GA 1-year stats
          declare -a paths=(
            "/"
            "/calculate-your-child-maintenance"
            "/check-vehicle-tax"
            "/get-information-about-a-company"
            "/government/organisations/companies-house"
            "/government/organisations/hm-revenue-customs"
            "/search"
            "/sold-bought-vehicle"
            "/state-pension-age"
            "/vehicle-tax"
          )

          for node in `govuk_node_list -c cache`; do
            for hostname in "${hostnames[@]}"; do
              for path in "${paths[@]}"; do
                ssh deploy@$node "curl -s -X PURGE $hostname$path"
              done
            done
          done
    wrappers:
      - ansicolor:
          colormap: xterm

---
- job:
    name: clear-cdn-cache
    display-name: Clear CDN cache
    project-type: freestyle
    description: >
      Clears the CDN cache for the 10 most popular pages on GOV.UK.
    properties:
      - build-discarder:
          num-to-keep: 30
    builders:
      - shell: |
          #!/usr/bin/env bash

          set -ex

          declare -a hostnames=(
            "<%= @website_root_url -%>"
            "<%= @assets_root_url -%>"
          )

          # 10 most popular pages based on GA 1-year stats
          declare -a paths=(
            "/"
            "/check-mot-history"
            "/coronavirus"
            "/get-coronavirus-test"
            "/log-in-register-hmrc-online-services"
            "/report-covid19-result"
            "/search/all"
            "/sign-in-universal-credit"
            "/sold-bought-vehicle"
            "/vehicle-tax"
          )

          for node in `govuk_node_list -c cache`; do
            for hostname in "${hostnames[@]}"; do
              for path in "${paths[@]}"; do
                ssh deploy@$node "curl -s -X PURGE $hostname$path"
              done
            done
          done
    wrappers:
      - ansicolor:
          colormap: xterm

Update most 10 popular paths to cache clear
Update most 10 popular paths to cache clear

[Card in 2nd line trello](https://trello.com/c/JUZX5TiZ/1161-update-popular-paths-in-clear-cdn-cache-jobdraft)

Platform health have plans to make this dynamic. Alex has raised a PR that
[reads the most popular over the last 2 weeks](https://github.com/alphagov/govuk-puppet/pull/11133/files)
from search-api. I'm not sure whether that's been tested yet.
