title: Google Cloud CDN serves stale content AFTER revalidation
body: <p>I am attempting to use Google Cloud CDN with the stale-while-revalidate feature (<a href="https://cloud.google.com/cdn/docs/serving-stale-content#serve-stale-while-revalidating" rel="nofollow noreferrer">Google Docs</a>). However, even though I can see asynchronous revalidation requests being made to my backend server, the new content is never served by the CDN.</p>
  <p>Here is an example of the response headers from the CDN:</p>
  <pre><code>HTTP/1.1 200 OK
  Access-Control-Allow-Origin: *
  Age: 5202
  Cache-Control: max-age=60, public, stale-while-revalidate=86400
  Content-Length: 90
  Content-Type: application/json
  Date: Tue, 08 Feb 2022 16:39:09 GMT
  Server: Development/1.0
  Via: 1.1 google
  </code></pre>
  <p>You can see that the age is 5205 seconds even though the max-age is 60 sec.</p>
  <p>If it has been more than 60 seconds since the last revalidation request, I will see the revalidation request in my server logs, but the content served from the CDN continues to be outdated on future requests.</p>
  <p>Here is an example of the response headers directly from my backend server:</p>
  <pre><code>HTTP/1.1 200 OK
  Access-Control-Allow-Origin: *
  Cache-Control: max-age=60, public, stale-while-revalidate=86400
  Content-Length: 645
  Content-Type: application/json
  Date: Tue, 08 Feb 2022 18:09:39 GMT
  Server: Development/1.0
  </code></pre>
  <p>And here is the Google Cloud Logging entry for the revalidation request. I believe it is showing that it received a 200 response as well:</p>
  <pre><code>{
    &quot;insertId&quot;: &quot;1sxvbdng2vrqnhl&quot;,
    &quot;jsonPayload&quot;: {
      &quot;parentInsertId&quot;: &quot;1sxvbdng2vrqng7&quot;,
      &quot;@type&quot;: &quot;type.googleapis.com/google.cloud.loadbalancing.type.LoadBalancerLogEntry&quot;,
      &quot;statusDetails&quot;: &quot;response_sent_by_backend&quot;,
      &quot;cacheId&quot;: &quot;LAX-ba56a406&quot;
    },
    &quot;httpRequest&quot;: {
      &quot;requestMethod&quot;: &quot;GET&quot;,
      &quot;requestUrl&quot;: &quot;***masked request url***&quot;,
      &quot;requestSize&quot;: &quot;1888&quot;,
      &quot;status&quot;: 200,
      &quot;responseSize&quot;: &quot;1259&quot;,
      &quot;userAgent&quot;: &quot;Cloud-CDN-Google (GFE/2.0)&quot;,
      &quot;remoteIp&quot;: &quot;***masked request ip***&quot;,
      &quot;cacheLookup&quot;: true,
      &quot;cacheFillBytes&quot;: &quot;1259&quot;,
      &quot;serverIp&quot;: &quot;***masked request ip***&quot;,
      &quot;latency&quot;: &quot;0.082249s&quot;
    },
    &quot;resource&quot;: {
      &quot;type&quot;: &quot;http_load_balancer&quot;,
      &quot;labels&quot;: {
        &quot;backend_service_name&quot;: &quot;test-be-service&quot;,
        &quot;target_proxy_name&quot;: &quot;test-lb-target-proxy&quot;,
        &quot;project_id&quot;: &quot;cdn-test-2-340220&quot;,
        &quot;zone&quot;: &quot;global&quot;,
        &quot;url_map_name&quot;: &quot;test-lb&quot;,
        &quot;forwarding_rule_name&quot;: &quot;test-lb-forwarding-rule&quot;
      }
    },
    &quot;timestamp&quot;: &quot;2022-02-08T19:36:48.094836Z&quot;,
    &quot;severity&quot;: &quot;INFO&quot;,
    &quot;logName&quot;: &quot;projects/cdn-test-2-340220/logs/requests&quot;,
    &quot;trace&quot;: &quot;projects/cdn-test-2-340220/traces/f6a372e62f789d61c3654e50111ffcb9&quot;,
    &quot;receiveTimestamp&quot;: &quot;2022-02-08T19:36:48.360094896Z&quot;,
    &quot;spanId&quot;: &quot;d20eb70cb8d7dff4&quot;
  }
  </code></pre>
  <p>This behavior is the same whether I activate stale-while-revalidate via the Cache-Control response header or the Cloud CDN configuration interface.</p>
  <p>Either I am not understanding how this is supposed to work, or this is a bug in Google Cloud CDN. Any help resolving this would be greatly appreciated.</p>