pcre_jit

The `pcre_jit` directive enables or disables Just-In-Time (JIT) compilation for PCRE regular expressions in NGINX.

Syntaxpcre_jit on | off;
Defaultoff
Contextmain
Argumentsflag

Description

The pcre_jit directive controls the use of Just-In-Time (JIT) compilation for regular expressions which are processed using the PCRE (Perl Compatible Regular Expressions) library. When JIT is enabled, the regular expressions are converted into native machine code for improved performance during pattern matching, which can significantly speed up processing of requests that rely on regular expressions in location matching or server directives.

This directive is available in the main context and can be set to either on or off. By default, JIT compilation is disabled (off). However, when enabled, it can improve the efficiency of NGINX operations that utilize regular expressions, particularly under high-load conditions. It’s essential to ensure that the PCRE library installed on the system supports JIT compilation, as not all builds of PCRE include this feature.

When utilizing the pcre_jit directive, administrators should note that while it can enhance performance, it may also lead to increased memory usage due to the storage of compiled regex patterns. Furthermore, certain edge cases can result in compatibility issues when using complex regular expressions; hence, it is advisable to thoroughly test configurations after enabling this directive.

Config Example

pcre_jit on;

JIT compilation may increase memory consumption due to storage of compiled patterns.

Ensure that the PCRE library installed has JIT support; otherwise, JIT will not be enabled despite the directive being set to 'on'.

Test configurations after changing this directive to avoid unexpected behavior with complex regex patterns.

← Back to all directives