How do i get the Cache Key of an object
I want to print the Cache Key of a request so that i can verify that we are only caching the object once. Our setup runs a multidomain site but the problem is within each apex domain there are subdomains like www, example1, example2 now i don't want to cache each page based on host within a given apex domain.
So i have written the following vcl snippet
set req.hash += req.url;
set req.hash += std.strstr(req.http.host, "myapexdomain");
set req.hash += "#####GENERATION#####";
set req.http.plpagehash = hash;
return (hash);
But i want to send back the Hash - Cache key as part of the response so i can make sure this really works. It seems like there is no way to get the string representation of the Hash object. Is there a way to send back the Cache key in a custom header.
-
Hi Pooranan
By default, the cache key includes the value of the Host header, so this means that the apex and subdomains will be cached separately. This means you shouldn't have to make any change to the vcl_hash function.
You mentioned you're looking to send 'back' the value of the cache key. Do you want it sent back to the origin or to the client making the request?
-
Justin thanks for your help. this helps with my appetizers project. i can see you do know what you're talking about so i was wondering if you can help me in case i'm going to have any questions. thanks in advance
-
Hi Jack Forrester. Yes, I can help here if you've got a general question, but your best bet is to email support@fastly.com if you have a specific issue you want help with.
Please sign in to leave a comment.
Comments
3 comments