Deploying Static Websites Using OSS and CDN on Alibaba Cloud

  1. No server is required to host the assets
  2. OSS stores redundant copies of the assets across multiple zones within a region; thus, region-level high availability is provided for the origin of the assets without the need to do anything additionally
  3. CDN is used to improve delivery and, thus, the user experience
  4. CDN is a massive global network of interconnected servers so high availability is provided at global level for the user facing servers
  5. OSS is very cheap

Prerequisites

  1. Aliyuncli and ossutil installed and configured. If you have Docker installed, a quicker alternative is to use the “python-toolbox” which includes both
  2. curl installed (alternatively, you can use a browser with the inspection functionality in sections where we inspect headers)
  3. Firm understanding of Object Storage Service (OSS) and Content Delivery Network (CDN)
  4. Essential Linux skills on a Linux box

Architecture

Implementation

OSS Bucket

# ossutil mb oss://angry-medusa
1.244258(s) elapsed
# ossutil ls oss://angry-medusa
Object Number is: 0
0.350505(s) elapsed

Upload to OSS

# ossutil cp . oss://angry-medusa –rf

OSS Static Page Feature

Adding the CDN

Locking OSS Down

Conclusion

# copy your assets over:
# ossutil cp . oss://angry-medusa –rf
# invalidate the cache through pull:
# aliyuncli cdn RefreshObjectCaches --ObjectType Directory --ObjectPath http://angry-medusa.me/
# invalidate through push
# aliyuncli cdn PushObjectCache --ObjectPath http://angry-medusa.me/ --ObjectTyp
e Directory
# party

Further Reading

  1. Alibaba Cloud CLI: https://github.com/aliyun/aliyun-cli
  2. OSSUTIL: https://www.alibabacloud.com/help/doc-detail/50452.htm?spm=a3c0i.l31815en.a3.107.4664aad5Ay6lpd
  3. CLI extensions: https://github.com/aliyun/aliyuncli-python-toolbox/tree/master/acs
  4. Docker image: https://hub.docker.com/r/aliyunca/aliyuncli-python-toolbox/
  5. GitHub repo for image: https://github.com/aliyun/aliyuncli-python-toolbox

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why I Choose Not to Use Cloud Apps and Services

Make your Laravel App Fly with PHP OPcache

Selenium NUnit Extent Framework

Drops 19 : XPeare — ‘XDT’

Best Boot Camp Alternative to Make a Bootable Win10 USB on Mac

Seeking Permission or Begging Forgiveness?

What Is Microkernel Architecture Design?

Trello & Todoist: the best solution with IFTTT

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

An overview of message brokers

Handle multiple databases in bitbucket Pipelines

We are in the era of API, and our services are exposed in APIs.

Perimeter security with Fastly edge and AWS — Part I