I have set up a GCP Cloud CDN with a backend bucket. My problem is sometimes cacheable contents are not getting cached.
For example, when I open an image in the bucket on Firefox or Chrome with the following in the response the image doesn't get cached:
Status: 200
Cache-Control: public,max-age=3600
Content-Length: 313695
which satisfy all requirements listed here:
https://cloud.google.com/cdn/docs/caching?authuser=1#cacheability
And my bucket is publicly available with allUsers with Storage Object Viewer permissions enabled.
When I curl -s -D - -o /dev/null http://example/foo/bar/image.jpeg, the image gets cached fine. And images under http://example/foo/ (no more subdirectories) all seem to get cached fine.
Why are my contents not getting cached?
EDIT: Chrome requests except the first one have the status 304 and statusDetails: "response_sent_by_backend" whereas curl requests have statusDetails: "response_from_cache". Also Chrome requests take 80-100ms for a 30kb image and curl gets it in 1ms.
EDIT2: Things are working as intended.