nginx expires directive without Cache Control header

Jesin asked:

Is it possible to use the expires directive in nginx to display the “Expires” header alone without the Cache-control ?

Also I’ve seen some websites whose max-age value decrements over time.

Example

Cache-Control: max-age=3600

After 10 mins changes to

Cache-Control: max-age=3000

How is this done ? Are there any advantages of doing this ?

Thanks for the reply.

I meant the expires directive of nginx. When I use it in my config it adds both the Expires header and Cache-Control: max-age header.

So how do I make it add only the Expires header ?


I answered:

Yes, you can use Expires without Cache-Control. However, if Cache-Control: max-age is present, it overrides Expires. See RFC 2616 section 14.21.

There is no reason to not have both headers. Some broken clients may only check one or the other.

As to the question of what max-age should be set to, this is entirely up to you.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.