Google Cloud CDN: How to Exclude Objects from Caching

How to Exclude Objects from Caching

Question

You have a storage bucket that contains two objects.

Cloud CDN is enabled on the bucket, and both objects have been successfully cached.

Now you want to make sure that one of the two objects will not be cached anymore, and will always be served to the internet directly from the origin.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.

https://developers.google.com/web/ilt/pwa/caching-files-with-service-worker

To ensure that one of the two objects in a storage bucket is not cached anymore and is always served to the internet directly from the origin, you should add a Cache-Control entry with the value "private" to the metadata of the object. This will invalidate all previously cached copies.

Option A, ensuring that the object is not shared publicly, will prevent the object from being accessed by the public, but it will not prevent it from being cached.

Option B, creating a new storage bucket and moving the object inside it, and then enabling the private attribute will also prevent the object from being accessed by the public, but it will not prevent it from being cached if Cloud CDN is still enabled on the new bucket.

Option C, adding an appropriate lifecycle rule on the storage bucket, will not necessarily prevent the object from being cached. Lifecycle rules are used to manage objects in a bucket over time, such as deleting or archiving them based on certain criteria.

Therefore, the correct answer is option D, which involves adding a Cache-Control entry with the value "private" to the metadata of the object. This will ensure that the object is not cached anymore and is always served to the internet directly from the origin.