The Site API can also be used to create invalidation objects, which force CDN cached files to be refreshed from the origin website.
Create (register) site
HTTP Operation: POSTURL: POST https://secure.metacdn.com/api/users/{username}/site
Auth: HTTP digest authentication (User)
"Content-Type" header: application/json
Expected HTTP response: HTTP/1.1 201 Created
Expected Format (mandatory, optional):
Notes:POST /api/users/{username}/site HTTP/1.1 Content-Type: application/json { "name": "", "domain": "" "description": "" "cnames": ["", ..., ""] }
- "name" is the site's identifier and will be used to generate the accelerated domain name.
- "domain" is the origin domain name of your site without any protocol (http:// or https://) and without any path (/index.html)
- You can have up to 5 CNAMEs for a site, please contact us if you need more than 5.
- You will get an error if you have reached your plan's allocated quota.
Expected Response #1:POST /api/users/mcdnuser/site HTTP/1.1 Content-Type: application/json { "name": "metacdn", "domain": "www.metacdn.com" "description": "Site acceleration for MetaCDN.com", "cnames": ["cdn.metacdn.com","cdn-2.metacdn.com"] }
HTTP/1.1 201 Created Content-Type: text/plain; charset=UTF-8 Content-Length: 12 Accept-Ranges: bytes Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept Date: Tue, 24 Jul 2012 06:41:23 GMT Server: Restlet-Framework/2.0.13 Connection: close Site created
Get site
HTTP Operation: GETURL: GET https://secure.metacdn.com/api/users/{username}/site/{siteName}
Auth: HTTP digest authentication (User)
"Accept" header: application/json
Expected HTTP response: HTTP/1.1 200 OK
Expected Format (mandatory, optional):
Example Call #1:GET /api/users/{username}/site/{siteName} HTTP/1.1 Accept: application/json
Expected Response #1:GET /api/users/mcdnuser/site/metacdn HTTP/1.1 Accept: application/json
Notes:HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Accept-Ranges: bytes Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept Date: Tue, 24 Jul 2012 06:43:33 GMT Server: Restlet-Framework/2.0.8 Content-Length: 197 Cache-Control: private, x-gzip-ok="" Connection: close { "name": "sitetest2", "description": "Site acceleration for MetaCDN.com", "username": "mcdnuser", "siteStatus": "READY", "originUrl": "www.metacdn.com", "useSSL": true, "cnames": [{ "cname": "cdn.metacdn.com", "active": "true", "disableTimestamp": null }, { "cname": "cdn-2.metacdn.com", "active": "true", "disableTimestamp": null } ]}
- "siteStatus" can be in the following states: PENDING, PROVISIONING, READY, DELETING, CANCELLED, UPDATING, ERROR
- Secure shared SSL will be supported when "useSSL" is enabled.
URL: GET https://secure.metacdn.com/api/users/{username}/site
Auth: HTTP digest authentication (User)
"Accept" header: application/json
Expected HTTP response: HTTP/1.1 200 OK
Expected Format (mandatory, optional):
Example Call #3:GET /api/users/{username}/site HTTP/1.1 Accept: application/json
Expected Response #3:GET /api/users/mcdnuser/site HTTP/1.1 Accept: application/json
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Accept-Ranges: bytes Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept Date: Tue, 24 Jul 2012 06:54:18 GMT Server: Restlet-Framework/2.0.13 Content-Length: 383 Cache-Control: private, x-gzip-ok="" Connection: close { "sites": [{ "name": "metacdn", "description": "Site acceleration for MetaCDN.com", "username": "mcdnuser", "siteStatus": "READY", "originUrl": "www.metacdn.com", "useSSL": true, "cnames": [{ "cname": "cdn.metacdn.com", "active": "true", "disableTimestamp": null }, { "cname": "cdn-2.metacdn.com", "active": "true", "disableTimestamp": null }] }, { "name": "sitetest", "description": "Site acceleration for test.com", "username": "mcdnuser", "siteStatus": "READY", "originUrl": "www.test.com", "useSSL": false, "cnames": [] }] }
Update site
HTTP Operation:PUTURL: PUT https://secure.metacdn.com/api/users/{username}/site/{siteName}
Auth: HTTP digest authentication (User)
"Content-Type" header: application/json
Expected HTTP response: HTTP/1.1 202 Accepted
Expected Format (mandatory, optional):
Notes:PUT /api/users/{username}/site/{siteName} HTTP/1.1 Content-Type: application/json { "description": "", "useSSL": true/false, "cnames": ["", "", ..., ""] }
- Secure shared SSL will be supported when "useSSL" is enabled.
Expected Response #1:PUT /api/users/test/site/testSite HTTP/1.1 Accept: application/json { "description": "This site will enable SSL support", "useSSL": true, "cnames": [ "css.test.com", "js.test.com" ] }
HTTP/1.1 202 Accepted Accept-Ranges: bytes Vary: Accept-Charset, Accept-Encoding, Accept-Language. Accept Date: Mon, 22 Apr 2013 07:11:20 GMT Content-Type: text/html Server: Google Frontend Site update is processing now
Delete site
HTTP Operation: DELETEURL: DELETE https://secure.metacdn.com/api/users/{username}/site/{siteName}
Auth: HTTP digest authentication (User)
Expected HTTP response: HTTP/1.1 202 Updated
Expected Format (mandatory, optional):
Example Call #1:DELETE /api/users/{username}/site/{siteName} HTTP/1.1
Expected Response #1:DELETE /api/users/mcdnuser/site/testsite HTTP/1.1
HTTP/1.1 202 Accepted Content-Type text/plain; charset=UTF-8 Date: Tue, 24 Jul 2012 06:57:28 GMT Accept-Ranges: bytes Server: Restlet-Framework/2.0.13 Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept Content-Length: 25 Connection: close Site scheduled for deletion
Create invalidation object
HTTP Operation:POSTURL: POST https://secure.metacdn.com/api/users/{username}/site/{siteName}/invalidation
Auth: HTTP digest authentication (User)
"Content-Type" header: application/json
Expected HTTP response: HTTP/1.1 201 Created
Expected Format (mandatory, optional):
Invalidated objects are removed from MetaCDN caches, and refreshed from your origin site.POST /api/users/{username}/site/{siteName}/invalidation HTTP/1.1 Content-Type: application/json { "objectPaths": ["", ""] }
Notes:
- "objectPaths" is a list of paths to the objects will be invalidated. It should start with "/" without any protocol (http:// or https://)
- You must explicitly invalidate every object and every directory that you want MetaCDN to refresh.
- You cannot use wildcards to invalidate groups of objects, and you cannot invalidate all of the objects in a directory by specifying the directory path.
- Invalidate all cached objects by specifying '*' as the path.
Expected Response #1:POST /api/users/mcdnuser/site/metacdn/invalidation HTTP/1.1 Content-Type: application/json { "objectPaths": ["/logo.png", "/index.html"] }
HTTP/1.1 201 Created Content-Type: text/plain; charset=UTF-8 Content-Length: 12 Accept-Ranges: bytes Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept Date: Tue, 24 Jul 2012 07:32:10 GMT Server: Restlet-Framework/2.0.13 Connection: close Invalidation objects created