Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My server returns the following headers:

Date:Thu, 07 Jul 2011 10:41:57 GMT
Expires:Thu, 01 Jan 1970 00:00:01 GMT
Last-Modified:Thu, 07 Jul 2011 08:06:32 GMT

I want the content I'm serving not to be cached, so I'm looking for a way to return a Last-Modified header that contains the date-time when the request was originated. Something like now()...

share|improve this question

1 Answer 1

up vote 3 down vote accepted

"I want the content I'm serving not to be cached" : You can turn off If-Modified-Since request header checking with if_modified_since off; directive. if_modified_since doc

And about Last-Modified header: You can turn it off with add_header Last-Modified "";

share|improve this answer
You can't turn off headers with add_header, you can only add them. From the entry: Note that it just appends a new header entry to the output header list. So you can't use this directive to rewrite existing headers like Server. Use the headers_more module for it. – kolbyjack Jul 7 '11 at 14:16
I've checked it with curl -D and after adding add_header Last-MOdified ""; to my nginx.conf, Last-Modified header is no longer there in dump file. – Casual Coder Jul 7 '11 at 16:54
Wow, looking at the source, Cache-Control and Last-Modified are special cased and will be set instead of having an extra entry added. It seems the wiki needs to be updated. – kolbyjack Jul 7 '11 at 18:03
I was wrong again, Cache-Control is special cased, but it doesn't overwrite, it just has to be added in a special way. Only Last-Modified sets the header instead of adding a new one. – kolbyjack Jul 7 '11 at 18:16
Good to know, could you point me to a file ? Is it in src/http/ngx_http_header_filter_module.c ? – Casual Coder Jul 7 '11 at 18:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.