sub_filter_last_modified

The sub_filter_last_modified directive allows controlling the Last-Modified header of proxied responses.

Syntaxsub_filter_last_modified on | off;
Defaultoff
Contexthttp, server, location
Argumentsflag

Description

The 'sub_filter_last_modified' directive is part of NGINX's HTTP core and is utilized in the context of http, server, or location blocks. This directive, when enabled, instructs NGINX to append a Last-Modified header to the responses it serves after applying any sub_filter replacements. The directive requires a flag that determines the behavior of how the header will be manipulated. If set to 'on', it will add or modify the Last-Modified header in the upstream response, which can be particularly useful when the content is dynamically generated and requires timestamping for caching mechanisms.

Config Example

location /example {
    sub_filter last_modified on;
    proxy_pass http://backend;
}

Ensure the 'sub_filter' directive is enabled, as 'sub_filter_last_modified' only modifies headers for responses where replacements are occurring.

Misconfiguring this directive can lead to improper cache behaviors; make sure to test header values in your responses.

← Back to all directives