Skip to content

Instantly share code, notes, and snippets.

@JiLiZART
Forked from korotovsky/nginx-retina-rewrite
Created February 14, 2014 16:59
Show Gist options
  • Save JiLiZART/9004795 to your computer and use it in GitHub Desktop.
Save JiLiZART/9004795 to your computer and use it in GitHub Desktop.
###
# Retina images handler
###
if ($http_cookie ~* "isRetina=1" ) {
set $isRetina "retina";
}
location ~ ^/bundles/(.*)-retina\.png {
try_files /bundles/$1-retina.png @retinaFallback;
}
location ~ ^/bundles/(.*)\.png$ {
if ($isRetina = "retina") {
rewrite ^/bundles/(.*).png$ /bundles/$1-retina.png last;
}
}
location @retinaFallback {
rewrite ^/bundles/(.*)-retina.png$ /bundles/$1.png break;
}
##
# End retina handler
##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment