We will use Google Cloud CDN to cache the objects in the backend bucket as follows.
$ gcloud compute backend-buckets describe xxx-backend-bucket
bucketName: xxx
cdnPolicy:
cacheMode: CACHE_ALL_STATIC
clientTtl: 0
defaultTtl: 60
maxTtl: 60
negativeCaching: false
requestCoalescing: true
serveWhileStale: 300
description: ''
enableCdn: true
kind: compute#backendBucket
name: xxx-backend-bucket
The metadata of the bucket object is set to cache-control: max-age=31536000
.
On the first request from the client, the CDN will return a 200 response and override the cache-control with max-age=0
. This is the expected behavior.
However, if there is an if-modified-since
in the request header from the client, the CDN will return a 304 response and the cache-control in the response header will be set to max-age=31536000
. The expected behavior is to set max-age=0
.
I'm having trouble with 304 responses because the cache-control is not overridden and is cached by the client for an unintentionally long time.
Is this a CDN specification?