Expiration headers when rewriting requests
Brian Kirkbride
brian.kirkbride at deeperbydesign.com
Wed Mar 12 00:27:46 MSK 2008
Hello,
I'm having trouble translating my setup into a working NginX config.
Any help is much appreciated -- I'm almost there, but not quite.
I need to rewrite URLs like /r1234567/xyz... to be simply /xyz... to
allow for versioned caching of resources (cache forever, change
revision in URL to force cache update).
A simple rewrite rule works to find the resource, but I need to set
the expiration headers to max for requests like this. I tried doing this:
location ~ ^/r[0-9]+/ {
expires max;
add_header Last-Modified "Thu, 01 Jan 1970 00:00:01 GMT"
rewrite ^/r[0-9]+(/.*)$ $1 last;
}
location / {
# check for a cached file, fallback to FastCGI, etc
}
But this doesn't work because the rewrite seems to wipe out the
headers when starting the request over. I tried the rewrite with
last, break and no flags -- nothing worked.
Any ideas?
Thanks in advance,
Brian
More information about the nginx
mailing list