Absolute rather than relative times in expires directives

Francis Daly francis at daoine.org
Mon Feb 1 09:14:20 UTC 2016

On Mon, Feb 01, 2016 at 12:24:22AM -0500, rgrraj wrote:

Hi there,

> Thank you all for  the suggestions and thoughts. 
> I did double check the nginx version I am having and it is 1.9.2. 

> but when I use the expires directive it shows invalid error same as before.
> Seems like to get the feature I need to update the nginx version.

All I can say is: it works for me.

"http" section of nginx.conf:

http {
    map $time_iso8601 $expiresc {
        default "3h";
        ~T22 "@00h00";
        ~T23 "@00h00";

    server {
        listen       8080;
        location /a/ {
            expires     $expiresc;

Selected output from

$  curl -i

HTTP/1.1 200 OK
Server: nginx/1.9.2
Date: Mon, 01 Feb 2016 09:09:06 GMT
Expires: Mon, 01 Feb 2016 12:09:06 GMT
Cache-Control: max-age=10800

If you get different output, it may be worth investigating properly what
is happening.

But it may be simpler to just deploy your tested-working version.

Good luck with it,

Francis Daly        francis at daoine.org

More information about the nginx mailing list