Is there a way to get the file name from a URL to use in Cache Keys?
Example:
*/movie.mp4
cacheKey: ‘movie.mp4’,
Is there a way to get the file name from a URL to use in Cache Keys?
Example:
*/movie.mp4
cacheKey: ‘movie.mp4’,
Why don’t you use the whole url as cacheKey ?
Assuming you’re using JS you can do:
const url = new URL(request.url);
// This will return "movie.mp4" if the URL is example.com/*/movie.mp4
const lastPart = url.pathname.substring(url.pathname.lastIndexOf('/') + 1);
then you can just use that lastPart
variable as you wish
The patch has hash content protection.
But the final content is the same.
*/hash1/movie.mp4
*/hash2/movide.mp4
These 2 URLs that I sent as an example have exactly the same content.
However, as they are in a different path, they do not share MISS and HIT.
With your previous thread, it appears you are attempting to deliver content with an access control token. If you are on a paid plan, you might use the built-in HMAC token validation with firewall rules. This gives you the protection you are looking for, without having to run a custom application.
It worked for me.
Thank you for your help.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.