Nginx: conditional "expires" directive
António P. P. Almeida
appa at perusio.net
Tue Aug 16 15:59:02 UTC 2011
On 16 Ago 2011 16h15 WEST, nginx-forum at nginx.us wrote:
> Nope still getting 304. Maybe something with rewrite and inside
> redirect?
It works here:
location /test {
if ($arg_no_caching) {
return 302 /test/t1;
}
location = /test/t1 {
expires epoch;
}
expires 1d;
}
Gives:
curl -I logs.damiao/test
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 16 Aug 2011 15:53:30 GMT
Content-Type: application/octet-stream
Content-Length: 0
Connection: keep-alive
Keep-Alive: timeout=10
Expires: Wed, 17 Aug 2011 15:53:30 GMT
Cache-Control: max-age=86400 <---
curl -I logs.damiao/test?no_caching=1
HTTP/1.1 302 Moved Temporarily <--
Server: nginx
Date: Tue, 16 Aug 2011 15:53:53 GMT
Content-Type: text/html
Content-Length: 154
Location: http://logs.damiao/test/t1
Connection: keep-alive
Keep-Alive: timeout=10
Expires: Wed, 17 Aug 2011 15:53:53 GMT
Cache-Control: max-age=86400 <---
There's something else in your config or backend that is interfering
with the desired behavior, I guess.
--- appa
More information about the nginx
mailing list