Welcome! Log In Create A New Profile

Advanced

Re: Value of "Expires" header differ for caching and content serving servers

Maxim Dounin
April 07, 2011 08:16AM
Hello!

On Wed, Apr 06, 2011 at 06:47:10AM -0400, i.s.ivanov2 wrote:

> I have a following servers structure:
> content.server contains an Apache instance, which processes one simple
> PHP script. On the same node Nginx is set as a caching proxy to that
> Apache.
> caching.server contains Nginx with proxy_cache directive, with upstream
> set to content.server
>
> Php script generates an XML file, that has a lifetime of 30 minutes.
> This is achieved by setting headers in PHP code: "Cache-Control:
> max-age=1800", "Date: now()" and "Expires: now()+1800seconds".
>
> content.server serves the cached file correctly:
> > Date Wed, 06 Apr 2011 09:50:49 GMT
> > Cache-Control public, must-revalidate, max-age=1800
> > Expires Wed, 06 Apr 2011 10:14:25 GMT
> > Etag 26ee7051c360ee28d2a5697fb2b97a03

This doesn't actually correct: Cache-Control max-age and Expires disagree.
According to max-age, document should expire at 10:20:49, while
expires set to 10:14:25.

Unless configured to ignore some headers (with
proxy_ignore_headers directive) nginx will use first relevant
header it sees to actually expire cached document, Cache-Control
max-age in this case.

> But approximately half of the time caching.server serves the content
> where Date header is larger than Expires, and Expires is different from
> the one on content.server:
> > Date Wed, 06 Apr 2011 09:49:58 GMT
> > Cache-Control public, must-revalidate, max-age=1800
> > Expires Wed, 06 Apr 2011 09:44:23 GMT
> > Etag 26ee7051c360ee28d2a5697fb2b97a03
>
>
> My questions is: what can cause such behaviour, when caching nginx sets
> its own Expires header?

Value of Expires header is preserved from original request, while
Date is current date on the server. Since document isn't expired
yet (see above), you see Expires in the past.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Value of "Expires" header differ for caching and content serving servers

i.s.ivanov2 April 06, 2011 06:47AM

Re: Value of "Expires" header differ for caching and content serving servers

i.s.ivanov2 April 06, 2011 07:39AM

Re: Value of "Expires" header differ for caching and content serving servers

i.s.ivanov2 April 07, 2011 07:46AM

Re: Value of "Expires" header differ for caching and content serving servers

Maxim Dounin April 07, 2011 08:16AM

Re: Value of "Expires" header differ for caching and content serving servers

Ryan Malayter April 07, 2011 03:56PM

Re: Value of "Expires" header differ for caching and content serving servers

Maxim Dounin April 07, 2011 09:28PM

Re: Value of "Expires" header differ for caching and content serving servers

i.s.ivanov2 April 11, 2011 01:37AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 256
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