$sent_http_last_modified
The $sent_http_last_modified variable contains the Last-Modified header returned by the server in the response to the client. — NGINX Core (HTTP)
Description
The $sent_http_last_modified variable is automatically set by NGINX during the processing of a request that involves fetching a resource. When NGINX responds to a request and includes a Last-Modified header in the HTTP response, this variable captures the value of that header. The Last-Modified header is used to indicate the date and time at which the resource was last modified, allowing clients to make decisions about caching or re-fetching the resource based on its freshness. This variable is useful in scenarios where caching behavior needs to be finely tuned or when implementing conditional GET requests using the If-Modified-Since header on the client side. By examining the value of $sent_http_last_modified, server-side logic can be implemented to alter headers or the content of responses based on the freshness of served resources. Typical values for this variable align with common HTTP date formats, such as 'Wed, 21 Oct 2015 07:28:00 GMT'. Note that if the Last-Modified header is not sent, the variable will be empty.
Config Example
location /example {
add_header Last-Modified $sent_http_last_modified;
}Subsystem
httpCacheable
YesContexts
http, server, location, ifIf the Last-Modified header is not set in the response, the variable will be empty, leading to unexpected behavior in configurations dependent on it.
Ensure your application logic checks if the variable is set before using it to avoid errors in processing.