Filter by Extension
With this feature, you can filter out requests by extension. For example, any static files attached to your website that don't need to go through our verification process.
We’ve already implemented for you a basic filter for the most common static files extensions: css, bmp, tif, ttf, docx, woff2, js, pict, tiff, eot, xlsx, csv, eps, woff, xls, jpeg, jpg, doc, ejs, otf, pptx, gif, pdf, swf, svg, ps, ico, pls, midi, svgz, class, png, ppt, mid, webp, jar
TO define an additional extension:
- Open the PX_CUSTOM.vcl file.
- Add the extension as a regex expression using req.url.ext.
EXAMPLE
sub px_custom_filter_by_extension {
if ((req.request == "GET" || req.request == "HEAD") && req.url.ext ~ "(?i)(css|bmp|tif|ttf|docx|woff2|js|pict|tiff|eot|xlsx|csv|eps|woff|xls|jpeg|jpg|doc|ejs|otf|pptx|gif|pdf|swf|svg|ps|ico|pls|midi|svgz|class|png|ppt|mid|webp|jar)$") {
set req.http.X-PX-filter-by:extension = "1";
}
}
To learn more about custom subroutines, see Customized subroutines.
TO enable the feature:
- Open the PX_CONFIG.vcl file.
- Set the px_filter_by_extension_enabled value to "true" (enabled). The default is "false" (disabled).
table px_configs {
"px_filter_by_extension_enabled": "true",
}
Test
- Send a request that includes the new filtered extension.
- Openthe console and search for your request. If you can't find the request, the feature is configured correctly.
Updated 12 days ago