compute@edge: Manipulating the cache key in Rust
I have just spent the last few hours porting our VCL service to into Rust code for a new WASM Fastly service. Literally the few lines of the VCL I need to port involve manipulating the cache key, which is a crucial part of our edge logic, but I can't find any API docs or reference to this being possible (d'oh!). In VCL we're doing something like this: https://docs.fastly.com/en/guides/manipulating-the-cache-key
In the docs here: https://developer.fastly.com/learning/compute/rust/#communicating-with-backend-servers-and-the-fastly-cache, we can see reference to `fastly::request::CacheOverride`, but only a single reference, despite what the text itself states. I assume this has been refactored in the 0.6 crate, and also assume it was just the `set_ttl` stuff anyway.
The question is, can I still set the cache key somehow? Would it be enough to manipulate the backend response to add a `Vary` header? I suspect not, because I want to set a different `Vary` header again in the response we send to clients.
Maybe it would be enough to set the `Vary` header on the backend request? That would be kind of random, but more in line with the `set_ttl` method which is also on the Request rather than on the backend's response.
It would be such a shame to have gotten this far and not be able to switch over to the new service because of this minor detail. I would be very happy to hear from anyone with experience on this, thanks in advance!
Did you come up with a solution for this?
I Found the reference for the CacheOverride enum that you also refer to (https://docs.rs/fastly/0.7.0/fastly/handle/enum.CacheOverride.html).
From what i can see (and understand 😅), It's a way to set the Surrogate Key, which seems to be happening under the hood from the HTTP Header.
So, what i'm looking for, is the equivalent of the vcl_hash. In my case I want to be able to have control over the cache key for GraphQL request.
Hope you found the missing piece 😊
Hello Geordie Jay and WE ARE HEAVY,
You are correct that we do not currently support manipulating the cache key with Compute@Edge. It is a functionality we plan to provide in the future, but it is unavailable at this time.
Please sign in to leave a comment.