May 17, 2018 12:50AM
Thank you for the response and useful information Francis incredibly helpful.

I am using the following function with this : http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_background_update

proxy_cache_background_update on;




My webapp outputting the X-Accel-Expires header is PHP like so.

CODE:
<?php
echo(gmdate('D, d M Y H:i:s', 0) . ' GMT');
?>
OUTPUT:
Thu, 01 Jan 1970 00:00:00 GMT

The 0 would be replaced by the time function what is a UNIX time stamp.

CODE:
<?php
echo(gmdate('D, d M Y H:i:s', time()) . ' GMT');
?>
OUTPUT:
Thu, 17 May 2018 04:47:38 GMT

I have noticed the formate on this is different to what you provided here :
>>$ date -d @0

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

Should it look like yours or Nginx will read and understand it in the format PHP is outputting it as ?


Francis Daly Wrote:
-------------------------------------------------------
> On Sat, May 12, 2018 at 12:05:51AM -0400, c0nw0nk wrote:
>
> Hi there,
>
> >
> http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_v
> alid
> >
> > 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
> format.
>
> f
> --
> Francis Daly francis@daoine.org
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

http://www.networkflare.com/
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: 268
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready