My server returns the following headers:

Cache-Control:no-cache
Connection:keep-alive
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
Server:nginx/0.8.46`

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()...

link|improve this question

feedback

1 Answer

up vote 2 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 "";

link|improve this answer
1  
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
show 4 more comments
feedback

Your Answer

 
or
required, but never shown

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