Model/Layout/LayoutPlugin.php
public function afterGenerateXml(\Magento\Framework\View\Layout $subject, $result)
    {
        // if subject is cacheable, FPC cache is enabled, Fastly module is chosen and general TTL is > 0
        if ($subject->isCacheable() && $this->config->isEnabled()
            && $this->config->getType() == Config::FASTLY && $this->config->getTtl()) {
            // get cache control header
            $header = $this->response->getHeader('cache-control');
            if (($header instanceof \Zend\Http\Header\HeaderInterface) && ($value = $header->getFieldValue())) {
                // append stale values
                if ($ttl = $this->config->getStaleTtl()) {
                    $value .= ', stale-while-revalidate=' . $ttl;
                }
                if ($ttl = $this->config->getStaleErrorTtl()) {
                    $value .= ', stale-if-error=' . $ttl;
                }
                // update cache control header
                $this->response->setHeader($header->getFieldName(), $value, true);
            }
        }

        /*
         * Surface the cacheability of a page. This may expose things like page blocks being set to
         * cacheable = false which makes the whole page uncacheable
         */
        if ($subject->isCacheable()) {
            $this->response->setHeader("fastly-page-cacheable", "YES");
        } else {
            $this->response->setHeader("fastly-page-cacheable", "NO");
        }

        return $result;
    }
public function afterGenerateXml(\Magento\Framework\View\Layout $subject, $result)
    {
        // if subject is cacheable, FPC cache is enabled, Fastly module is chosen and general TTL is > 0
        if ($subject->isCacheable() && $this->config->isEnabled()
            && $this->config->getType() == Config::FASTLY && $this->config->getTtl()) {
            // get cache control header
            $header = $this->response->getHeader('cache-control');
            if (($header instanceof \Zend\Http\Header\HeaderInterface) && ($value = $header->getFieldValue())) {
                // append stale values
                if ($ttl = $this->config->getStaleTtl()) {
                    $value .= ', stale-while-revalidate=' . $ttl;
                }
                if ($ttl = $this->config->getStaleErrorTtl()) {
                    $value .= ', stale-if-error=' . $ttl;
                }
                // update cache control header
                $this->response->setHeader($header->getFieldName(), $value, true);
            }
        }

        /*
         * Surface the cacheability of a page. This may expose things like page blocks being set to
         * cacheable = false which makes the whole page uncacheable
         */
        if ($subject->isCacheable()) {
            $this->response->setHeader("fastly-page-cacheable", "YES");
        } else {
            $this->response->setHeader("fastly-page-cacheable", "NO");
        }

        return $result;
    }
Set appropriate Cache-Control headers
Set Fastly stale headers if configured

@param \Magento\Framework\View\Layout $subject
@param mixed $result
@return mixed