How can I invalidate Google Cloud CDN cache from my express server?

Viewed 2388

Is there a way to invalidate / clear cached content on Cloud CDN from my express server?

For example, if I'm generating server rendered content to make it readily available and I update a specific route from my website, like editing a blogPost, for example. I need to do the following:

export const editBlogPostHandler = (req,res,next) => {
  // 1. UPDATE BLOGPOST WITH SLUG some-blogpost-slug ON DB
  // 2. INVALIDATE /some-blogpost-slug ROUTE ON CLOUD CDN CACHE
  // THIS IS NECESSARY FOR NEW REQUESTS TO GET FRESH DATA RATHER THAN A STALE DATA RESPONSE
};

How can I do that from my express server?


From Cloud CDN - Invalidating Cached Content:

You can invalidate cached content from Cloud CDN through these methods:

  • Using the console:

enter image description here

  • Using gcloud SDK:

enter image description here

1 Answers
Related