html_sanitize_hash_bucket_size
The `html_sanitize_hash_bucket_size` directive sets the size of the hash buckets used for HTML sanitization within the NGINX HTML Sanitization module.
Description
The html_sanitize_hash_bucket_size directive is a configuration parameter that affects the behavior of the NGINX module designed to sanitize HTML content. This module utilizes hash tables for efficient storage and retrieval of whitelisted elements, attributes, and CSS properties that are allowed through sanitization. By adjusting the value of this directive, users can control the size of the hash buckets, which directly influences the performance and memory usage of the HTML sanitization process.
Buckets are structures used in hash tables to manage collisions, where multiple elements hash to the same index. A proper size allows for optimal distribution of entries across the buckets, reducing the likelihood of collisions and maintaining fast access times. Setting this value too low may lead to increased collisions and degraded performance, while excessively high values could waste memory resources. Choosing an appropriate html_sanitize_hash_bucket_size depends on the expected variety and quantity of HTML attributes and elements processed by the NGINX server.
Config Example
location /sanitize {
html_sanitize on;
html_sanitize_hash_bucket_size 64;
}Setting the bucket size too low can lead to performance issues due to hash collisions.
Ensure that the bucket size aligns with the expected number of unique elements and attributes to be sanitized.