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()...
"I want the content I'm serving not to be cached" : You can turn off
If-Modified-Since
request header checking withif_modified_since off;
directive. if_modified_since docAnd about
Last-Modified
header: You can turn it off withadd_header Last-Modified "";
You may want to make it look like a file is always modified:
As for the last line, if you really want to hide a true last-modified date, then you must hide the
ETag
header too since it leaks timestamps.I've honestly spent a whole day on this and not closer to getting Nginx to play along properly especially with the way Nginx incorrectly formats the Last-Modified: Date header which is not within the RFC's for a Last-Modified header.
I found this solution however which, if you are using PHP, works just fine and can be tweaked as you need. Hope it helps. Just include this at the very top of your .php pages before the rest of your code.
Then test your site at redbot.org and www.hscripts.com
UPDATE: