I’m using an edge function to rewrite HTML responses to pre-built DCZ-compressed versions (ZSTD compression dictionaries), it’s all working except I can’t seem to negate functions using excludePath in the netlify.toml file as per the documentation here.
My configuration is as follows:
[[edge_functions]]
function = "compression-dictionary-rewrite"
path = "/*"
excludedPath = "/*.dcz"
[edge_functions.header]
accept = "text/html"
accept-encoding = "dcz"
available-dictionary = true
dictionary-id = true
My function contains a log message that (if the config is working properly) should never be output:
// we don't rewrite requests that are already for .dcz files
if (url.pathname.toLowerCase().endsWith(".dcz")) {
console.log("Request is already for a .dcz file, skipping dictionary rewrite.");
return;
}
But this is appearing in my logs (see last line below):
01KAPGEK info [compression-dictionary-rewrite] Compression Dictionary Rewrite Edge Function invoked for /
01KAPGEK info [compression-dictionary-rewrite] Rewriting / to /index.html-b133bf1c52766a9023afe70952fb0039.dcz
01KAPGEK info [compression-dictionary-rewrite] Compression Dictionary Rewrite Edge Function invoked for /index.html-b133bf1c52766a9023afe70952fb0039.dcz
01KAPGEK info [compression-dictionary-rewrite] Request is already for a .dcz file, skipping dictionary rewrite.
Is there some reason this isn’t working? I’ve tried testing the excludedPath with URLPattern (as per other threads on the forum) and it should match, so those requests should be ignored?