What does it do?
When a user requests an asset such as an image, CSS file, or HTML document, the request goes through the StackPath CDN edge network. If the StackPath CDN server already has the asset, it is served from cache instead of requesting it directly from the origin server. If the asset isn't cached on the CDN then the CDN pulls it from the origin server and stores it in its cache.
StackPath creates a unique cache key for each resource it stores in cache. A cache key is an "ID" for each resource that StackPath stores in cache. Keys are unique and are constructed from several variables such as protocol, like HTTP or HTTPS, and URL.
The Vary header allows customers to to create a specific cache version of assets based on the value of the Vary header. Many open source CMS plugins provide a Vary header value.
When and how should I use it?
The Vary header follows the syntax:
Vary: <header-name>
For example, if your origin sends the "Vary: Accept-Encoding" header, StackPath's CDN uses the "Accept-Encoding" request header value to create a specific cache key from the Accept-Encoding header value (if it exists), the protocol, and URL of the request.