Retrieving the Latest CV Timestamp
The cache invalidation facilitated by Storyblok through the use of the cv
(cache version) query parameter enables access to the most recent version of content. This can either be a server-side generated timestamp that receives an update if Storyblok's webhooks are triggered by a publish
event, or it can be fetched every time the application boots up.
Example Request and Response
Request
curl "https://api.storyblok.com/v2/cdn/spaces/me/?cv=CURRENT_TIMESTAMP&token=ask9soUkv02QqbZgmZdeDAtt" \
-X GET \
-H "Accept: application/json" \
-H "Content-Type: application/json"
Request
// Using the Universal JavaScript Client:
// https://github.com/storyblok/storyblok-js-client
Storyblok.get('cdn/spaces/me/', {
"cv": "CURRENT_TIMESTAMP"
})
.then(response => {
console.log(response)
}).catch(error => {
console.log(error)
})
Request
$client = new \Storyblok\Client('YOUR_STORYBLOK_SPACE_ACCESS_TOKEN');
$client->get('/v1/spaces/me/', [
"cv" => "CURRENT_TIMESTAMP"
])->getBody();
Request
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
client.space({:params => {
"cv" => "CURRENT_TIMESTAMP"
}})
Request
HttpResponse<String> response = Unirest.get("https://api.storyblok.com/v2/cdn/spaces/me/?cv=CURRENT_TIMESTAMP&token=ask9soUkv02QqbZgmZdeDAtt")
.asString();
Request
var client = new RestClient("https://api.storyblok.com/v2/cdn/spaces/me/?cv=CURRENT_TIMESTAMP&token=ask9soUkv02QqbZgmZdeDAtt");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Request
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "https://api.storyblok.com/v2/cdn/spaces/me/?cv=CURRENT_TIMESTAMP&token=ask9soUkv02QqbZgmZdeDAtt")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)
request.method = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Request
import requests
url = "https://api.storyblok.com/v2/cdn/spaces/me/"
querystring = {"cv":"CURRENT_TIMESTAMP","token":"ask9soUkv02QqbZgmZdeDAtt"}
payload = ""
headers = {}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)
Response
{
"space": {
"id": 123456,
"name": "Storyblok",
"domain": "https://storyblok.com/",
"version": 1710505066,
"language_codes": []
}
}