Today, I am presenting six best practices for optimizing and speeding up content delivery with Cloud CDN.
As the origin of a cacheable material, Cloud CDN uses HTTP(S) load balancing. An external HTTP(S) load balancer is capable of using a global IP address for transmission from the virtual machine instance (VM) instance group Compute Engine and/or Cloud Storage partition mixed static and dynamically generated content data.
Since Cloud CDN has seamless integration with Google Cloud, Cloud CDN can be used and content can be managed in a number of ways. To prepare and optimize your deployment, please use the good practice mentioned below:
Automatically cache static content
When Cloud CDN is enabled, you can automatically cache static content by allowing Cloud CDN to work better. For a static response from the source station automatically cached, you can use the –cache mode=CACHE_ALL_STATICset (default). Cloud CDN can cache common static content types with this setting.Also, Read Why you should move to Content Delivery Network (CDN)
Update content with versioned URLs:
You may have various versions of the same content by versioning content. Thus, before cache entries expire, you can expose new content to users and uninstall old content efficiently. Since version control is simple to use and does not charge any fees, the standard method of updating cacheable content is version control.
Add a URL parameter, such as a version number, for version-controlling content. Parameters may be used in the URL by various means, such as:
- Add query string:file.ext?v=100
- Change the file name: file.1.0.0.extorfile_v100.ext
- Change the file path:/v100/file.ext
You’ll modify the name and URL of the file when adding parameters. This update obliges the cache to ignore all cache entries remaining.
Use invalidation carefully to remove content
The invalidation procedure removes the material from the cache server distributed through Cloud CDN before the entry in the cache expires. The process of the failure has coherence.
I recommend you take note of the invalidation operation and can only do this as a last resort. For example, if you have to delete content for legal purposes or accidental upload, invalidation is useful. In such instances, the version control should be used or the content should expire as soon as possible. Cloud CDN cache servers usually remove contents that are seldom accessed to make new contents possible. If an object is not accessed for thirty days, it is unconditionally deleted.
There is a limited rate of cache invalidation.
Set expiration time for time-sensitive content
Each object has a corresponding expiry period in the Cloud CDN cache. Make sure you set your use case with an expiration period. Since the original server has to submit expired content back to the cache server, the expiry period must be carefully selected.
One way to choose the expiry time is to classify the material according to how frequently you change it.
- Almost real-time alerts such as real-time sports or transportation reviews
- Frequent updates, such as weekly, daily, or hourly weather information or front-page news pictures
Next, by type of material, pick the expiry period. For example, a five-second expiry period may be appropriate for almost real-time sports scores, and a one-hour expiry time may be appropriate for weather dynamics. Using the expiry time of Cache-Control metadata for the content stored in Cloud Storage. The expiration period can be controlled by the web server software when content is being provided by Compute Engine.
Cache-Control header expiry time max-age and s-manage the value defined. The HTTP specification defines this header. The Cache-Control header below, for example, says that cache expiry times are 73 hours (249,200 seconds) that the content will read and cache:
Use signed URL
Please note that if you use a signed URL:
- Keep your private and public content in different Cloud Storage locations.
- Follow security best practices.
View third-party performance testing
You can access third-party reports like availability, latency, and throughput reports that can support you in analysis a lot.