How to Use Google Drive as Free CDN for your website (Content Delivery Network)
After Google introduce Google Drive site publishing feature, Now you can upload static files like CSS,HTML & Javascript . Since Google is offering 15GB of free space you have enough space to upload images and video files as well. .Still when comparing to cheap shared hosting, google drive is a good solution because Google have servers with lot of resource and they have servers in multiple locations which helps to deliver your content faster than normal shared hosting server.
Let’s Start..
- First thing is you will need a Google account for this.
- Once your Google account is ready login to Google Drive via https://drive.google.com
- Then create a folder and name it as anything you want.
- Once your folder is created, Right click on the folder, there will be menu popup, Find the share settings and hit on it.
- Once you click on the share settings it will open up a another form like bellow picture. You can find small link to “Advance Settings”. Click on it..
Once you are inside you can see that “Who has access” settings is by default set to “Private – Only you can access”. Change it to “Public on web” and save it.
Now just copy your website files into that folder you created.
Then copy the folder ID from the address bar. Once you are inside the folder you created, The address in the address bar should look like bellow address
“https://drive.google.com/drive/u/0/folders/0ByGpd2QD5Q_kiWW52eV96aVNzN1E” and the folder ID is the part after “https://drive.google.com/drive/u/0/folders/”
So folder ID is 0ByGpd2QD5Q_kiWW52eV96aVNzN1E
Now your website is alive at http://googledrive.com/host/YOUR_ID_HERE. Please replace the YOUR_ID_HERE with your Folder ID. So in this case it should be http://googledrive.com/host/0ByGpd2QD5Q_kiWW52eV96aVNzN1E
Creating sub-domain for your CDN
You will need to create a sub-domain for this..
Log in to your domain control panel (e.g. Godaddy) Your Account > Domain > Your Domain > Manage Domain > All Host Records > Create a new sub-domain > Click Save (Name your subdomain as static)
Host Name: static
IP Address/URL: http://googledrive.com/host/folder-id
Record Type: URL Redirect
TTL: 1800
Now you can use this new sub-domain as your CDN URL like this http://static.domain.com/image.jpg.
If you found this article helpful, then please share it with someone else by using the buttons in the left. Thank you!