Welcome! Log In Create A New Profile

Advanced

Rewrite rule for cache busting URLs

June 09, 2010 11:21AM
Our application uses versioned URLs like http://domain.com/r123456789/resource/uri to allow for aggressive caching and easy cache invalidation.

To get this working in nginx, I currently have a config like this:

[code]
#################################################
set $cache_control '';

location ~ ^/r\d+/ {
set $cache_control 'public, max-age=2592000'; # 30 days
rewrite ^/r\d+(/.*)$ $1 last;
}

location /some/resources {
if ( $cache_control ) {
add_header Cache-Control $cache_control;
}
alias /path/to/resources;
}

location /some/other/resource {
if ( $cache_control ) {
add_header Cache-Control $cache_control;
}
alias /some/other/path;
}
#################################################
[/code]

Is this a bad idea? Likely to fail in the future? Anyone know a better way?

Could the HTTP Headers module be improved to allow "expires" or "add_header" to be used inside an "if" condition?

Thanks in advance!

Best,
Brian
Subject Author Posted

Rewrite rule for cache busting URLs

bkirkbri June 09, 2010 11:21AM

Re: Rewrite rule for cache busting URLs

Igor Sysoev June 09, 2010 11:32AM

Re: Rewrite rule for cache busting URLs

bkirkbri June 09, 2010 12:13PM

Re: Rewrite rule for cache busting URLs

Igor Sysoev June 09, 2010 02:36PM

Re: Rewrite rule for cache busting URLs

bkirkbri June 09, 2010 03:56PM

Re: Rewrite rule for cache busting URLs

Igor Sysoev June 09, 2010 04:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 53
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready