Cache busting with nginx

Here's a little snippet for cache busting without abusing a query string which can lead to caching problems.

The example below will rewrite paths like /css/foo_20130401-5.css to /path/to/static/css/foo.css on the static.example.com host.

Raw
server {
    server_name static.example.com;
    root /path/to/static/;
    location ~* ^/(\w+)/(\w+)_[\d-]+\.(css|js) {
        alias /path/to/static/$1/$2.$3;
        expires max;
    }   
}

0 comments

Start a new thread

Cancel reply
DjangoPythonBitcoinTuxDebianHTML5 badgeSaltStackUpset confusedMoneyHackerUpset confusedX.OrggitFirefoxWindowMakerBashIs it worth the time?i3 window managerWagtailContainerNginxSilenceTorWorldInternet securityFont