Possibly Most Important Parameter to Change is TTL or Expires. We Have Pointed How To Change CDN Object Metadata in HP Cloud CDN With cURL. We observed to get the data written as metadata but unfortunately we could not change the Expires or TTL. HP Cloud CDN means we are communicating with Akamai CDN Service via HP Cloud OpenStack Swift as HP Cloud’s Customer, it is not exactly easy to predict except being HP’s employee what values can be changes or has bug. There is zero visible effort from HP so far for setting setting the expire far ahead, so this might bring some help to the next person who might be able to write or change the expire or TTL. We are talking about object TTL or Expires. Container expire, TTL etc. should be set to higher.
Guide to Read Before Attempting To Change CDN Object Metadata in HP Cloud CDN
You should read this guide to authenticate in HP Cloud CDN. This is first step. Second step is learning about unix & epoch time stamp. Some of these values will need it instead of normal time in seconds. Searching the web with Epoch & Unix Timestamp Conversion Tools will give some easy to use tools.
Change CDN Object Metadata in HP Cloud CDN With cURL
If you hit the button cum dropdown named “View Details” on the Container name on HP Horizon Web GUI Admin panel, after some modification from the web GUI, you will get some data like these :
---
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Container Name security-garden Container URL https://region-a.geo-1.objects.hpcloudsvc.com/v1/xxxxxxxxxx/security-garden Container Access Public (access via Container URL) CDN URLs http://h3eaa823f452f54f42b7273b36a68e456.cdn.hpcloudsvc.com https://a248.e.akamai.net/cdn.hpcloudsvc.com/h3eaa823f452f54f42b7273b36a68e456/prodaw2/ CDN Time to Live 1577836800 seconds Object Count 15 Size 72.8 KB |
Note that https://region-a.geo-1.objects.hpcloudsvc.com/v1/xxxxxxxxxx/security-garden
. We will need this URL. Use a test container and upload one object via GUI and publish via CDN.
xxxxxxxxxx
is basically the project ID or rather OS_TENANT_ID
, we are getting ready to use format as URL from Web GUI. security-garden
is the container name.
If we do cURL of a file on CDN before the attempt to change any metadata :
1 | http://h3eaa823f452f54f42b7273b36a68e456.cdn.hpcloudsvc.com/center_cloud.gif |
We will get these data publicly :
1 2 3 4 5 6 7 8 9 10 11 12 | ~ curl -I http://h3eaa823f452f54f42b7273b36a68e456.cdn.hpcloudsvc.com/center_cloud.gif HTTP/1.1 200 OK Last-Modified: Tue, 14 Apr 2015 22:33:26 GMT ETag: "8f5f7aa1cb94c3953664414b35e461d0" Content-Length: 2231 Accept-Ranges: bytes Content-Type: image/gif X-Trans-Id: tx81a9a8fbfc91457e85c0b-00557ad0aa Cache-Control: public, max-age=0 Expires: Fri, 12 Jun 2015 12:29:30 GMT Date: Fri, 12 Jun 2015 12:29:30 GMT Connection: keep-alive |
Note these two values :
1 | Cache-Control: public, max-age=0 |
1 | Expires: Fri, 12 Jun 2015 12:29:30 GMT |
If any of the values – Cache-Control: public, max-age=
or TTL
or Expires
is increased on HP Cloud OpenStack Object, it would reflect on the CDN. We can read the previous guide now and fetch the metadata internal URL. Suppose your Auth is HPAuth10_2255
, then the command will be :
1 | curl -i -k -X HEAD -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'X-Auth-Token: HPAuth10_2255' https://region-a.geo-1.objects.hpcloudsvc.com/v1/xxxxxxxxxx/security-garden/center_cloud.gif |
Try to understand where from the xxxxxxxxxx
and /security-garden
came from above discussed topic. You will get this response :
1 2 3 4 5 6 7 8 9 10 | HTTP/1.1 200 OK Content-Length: 13503 Accept-Ranges: bytes X-Object-Meta-Expires: 2380880912 Last-Modified: Fri, 12 Jun 2015 12:18:21 GMT Etag: 3805e6d500919bd42889acde9c975363 X-Timestamp: 1434111501.57582 Content-Type: application/json X-Trans-Id: tx8f3e106cde8e42d6b22e4-00557ad2ac Date: Fri, 12 Jun 2015 12:38:04 GMT |
We should make sure that with our username
, we have the full read and write access to the container :
1 2 3 | curl -X POST -H 'X-Auth-Token: HPAuth10_2255' -H 'X-Container-Read: username' https://region-a.geo-1.objects.hpcloudsvc.com/v1/10577961648287/security-garden/ # curl -X POST -H 'X-Auth-Token: HPAuth10_2255' -H 'X-Container-Write: username' https://region-a.geo-1.objects.hpcloudsvc.com/v1/10577961648287/security-garden/ |
We can compose a POST request to change the metadata :
1 | curl -i -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'X-Auth-Token: HPAuth10_225' -H 'X-CDN-Enabled: True' -H 'X-Object-Meta-Expires: 2380880912' https://region-a.geo-1.objects.hpcloudsvc.com/v1/xxxxxxxxxx/security-garden/center_cloud.gif |
There are 03 types of Meta – X-Account-Meta, X-Container-Meta and X-Object-Meta. We can see that X-Object-Meta-
in that above example and change that X-Object-Meta-Expires: 2380880912
part to :
1 2 3 4 5 | X-Object-Meta-Expires X-Object-Meta-TTL X-TTL X-Delete-After X-Delete-At |
X-Delete-At
and X-Delete-After
actually not exactly what it sounds to be.
‘X-CDN-Enabled: True’ can be omitted from the command. Only the X-Delete-At needs the unix Epoch timestamp among the variables above. Others are in seconds.
After running a command successfully, we will receive a HTTP 202 response as well as a HTML output declaring the success :
1 2 3 4 5 6 7 | HTTP/1.1 202 Accepted Content-Length: 76 Content-Type: text/html; charset=UTF-8 X-Trans-Id: txd6ff2bfcd06a4a19a15a5-00557ac7ed Date: Fri, 12 Jun 2015 11:52:13 GMT <html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>% |
You will get documentation on official websites OpenStack and HP Cloud.
Tagged With does a cdn have ability to keep metadata