0

I am using a magento application and I need to cache only the "/media" path where images are stored on Google Cloud CDN.

Actually I've configured one instance group where my VM is running the whole website application and enabled Google Cloud CDN via the checkbox on the backend part.

It appears that every http request are send to Google Cloud CDN.

How to cache only the media path files ?

Bio
  • 103
  • 2

1 Answers1

2

You should use separate backends and the URL Map feature of the HTTP Load Balancer.

Based on URL Map, the Target HTTP Proxy will check each request and determine the appropriate backend service for the request. This way you can enable or disable Cloud CDN use for a particular backend (which means for a particular URL) with a single checkbox.

The Host and path rules are configured as part of the HTTP Load Balancer in the Cloud Console menu:

GCP Navigation => Networking => Network Services => Load balancing 
=> Create load balancer => HTTP(S) Load Balancing => Start configuration 
=> From Internet to my VMs => Host and path rules

enter image description here

Load Balancing > Doc > URL maps overview

Load Balancing > Doc > Using URL maps

mebius99
  • 2,495
  • 1
  • 5
  • 9
  • Thanks for the clear answer! The problem now will be to choose a new backend for images , maybe a bucket one .. An other problem is the website write a lot of product images everyday so I will need to sync new images with gsutil on the bucket or mount the bucket on the instance directly(I was investigating gcsfuse today...) – Bio Jun 09 '20 at 16:26