Francis Daly
May 16, 2018 06:44PM
On Sat, May 12, 2018 at 12:05:51AM -0400, c0nw0nk wrote:

Hi there,

> The “X-Accel-Expires” header field sets caching time of a response in
> seconds. The zero value disables caching for a response. If the value starts
> with the @ prefix, it sets an absolute time in seconds since Epoch, up to
> which the response may be cached.
> Can someone give an example of how this should look and what if i set it as
> zero what is the outcome then...?

The upstream sometimes wants to say "this is valid for an hour", and
sometimes wants to say "this is valid until midnight". "For an hour"
is "3600". "Until midnight" could be "work out the time difference
between now and midnight, and set that number". Or it could be "when is
midnight? Set @-that number".

The @-prefix is for when you want a thing to be cached until a specific
time, rather that for a specific duration.

You can find the number to use by, for example, using

$ date -d 'tomorrow 0:0' +%s

and it will probably be 10 digits long.

> //unknown outcome / result...?
> X-Accel-Expires: @0

$ date -d @0

will say something corresponding to "Thu Jan 1 00:00:00 UTC 1970".

So this asks to "cache until 1970". Which is in the past, so possibly is
"expire cache now"; but if you really want to expire the cache now you
should do just that.

> //Expire cache straight away.
> X-Accel-Expires: 0

"disables caching" is what the documentation says.

> //Expire cache in 5 seconds
> X-Accel-Expires: 5

"Cache for 5 seconds". That's probably the same thing.

> //Expire cache in 5 seconds and allow "STALE" cache responses to be stored
> for 5 seconds ?????
> X-Accel-expires: @5 5

The documentation you quoted doesn't seem to mention anything about STALE,
or spaces in the header value. It looks like invalid input to nginx to
me, so nginx could do anything (or nothing) with it.

> Hopefully I am right thinking that the above would work like this need some
> clarification.

Request to cache for a duration -> use the number of seconds.

Request to cache until a time -> use @ and the time stamp in a particular

Francis Daly
nginx mailing list
Subject Author Posted

Nginx Cache | @ prefix example

c0nw0nk May 12, 2018 12:05AM

Re: Nginx Cache | @ prefix example

Francis Daly May 16, 2018 06:44PM

Re: Nginx Cache | @ prefix example

c0nw0nk May 17, 2018 12:50AM

Re: Nginx Cache | @ prefix example

Francis Daly May 17, 2018 03:16AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 89
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready