Bypass Headers

If you want to bypass the GraphCDN Edge Cache for specific requests you need to define a set of Bypasse Cache Headers and then include them in your GraphQL request.

To configure those headers you can use the graphcdn.yml and the bypassCacheHeaders field that accepts a list of headers to look for.

name: my-app
schema: https://end.point
originUrl: https://end.point
bypassCacheHeaders:
    - name: preview-token
    - name: some-other-token
...

Alternatively you can also configure Bypass Cache Headers via the Cache settings on the dashboard of your service.

Bypass Cache Headers setting on your Cache configuration settings.Bypass Cache Headers setting on your Cache configuration settings.

Bypass Cache Headers setting on your Cache configuration settings.

A sample query using a Bypass Cache Header can be seen below

curl --request POST \
  --url https://spacex-api.graphcdn.app/ \
  --header 'Content-Type: application/json' \
  --header 'preview-token: 1' \
  --data '{"query":"{ launchesPast(limit: 5) { mission_name launch_date_utc launch_site { site_id site_name site_name_long } } }"}'

If you then take a look at the response headers for that request you will find the following headers indicating the request was passed on to your origin service.

gcdn-cache: PASS
gcdn-passed-through-request: "bypass-cache-header:preview-token"

The gcdn-passed-through-request response header will indicate which bypass header was used in the request.

🚧

Bypass Cache Headers and currently cached responses

This feature relies on the Vary header, which is stored with cached responses.

Since we can not update this header for stored responses, changes you make to your Bypass Cache Headers configuration will not apply to cached responses until they either get purged or expire.


Did this page help you?