secure_token_expires_time
The secure_token_expires_time directive specifies the expiration time for non-tokenized responses in NGINX.
Description
The secure_token_expires_time directive is used in the Secure token module for NGINX to define the expiration time of responses that do not have a secure token applied to them. This directive is particularly important for managing cache control as it influences the Cache-Control and Expires HTTP headers that are included in the response. By setting an appropriate expiration time, administrators can control how long responses are cached by clients and intermediary caches, which is crucial for ensuring that users receive updated content in a timely manner.
The directive accepts a time parameter that can be specified in various formats (e.g., seconds, minutes, hours). When a request is processed, if it does not contain a token, the server applies the expiration time defined by this directive to the response's HTTP headers. This is part of the module's broader functionality to manage secured content delivery via CDN systems such as Akamai and Amazon CloudFront. Setting an appropriate expiration time helps prevent stale content from being served while balancing cache efficiency.
The context for secure_token_expires_time includes http, server, and location, allowing for flexible configuration depending on the desired scope. For example, setting this directive globally in the http block would apply to all configured servers, while specifying it in a location block would limit its application to that specific URL pattern. This allows fine-grained control over how different types of resources are cached and served to end users.
Config Example
http {
secure_token_expires_time 1h;
server {
location /secure-content {
secure_token_expires_time 30m;
}
}
}Ensure that the time format is correctly specified; invalid formats may lead to unexpected behavior.
Setting overly long expiration times may lead to serving stale content to users.
This directive only applies to non-tokenized responses; ensure you set related directives for proper token management.