Skip to content

Instantly share code, notes, and snippets.

@thatryan
Created March 27, 2020 17:58
Show Gist options
  • Save thatryan/82c2017aede958a61172bf3f597a3b72 to your computer and use it in GitHub Desktop.
Save thatryan/82c2017aede958a61172bf3f597a3b72 to your computer and use it in GitHub Desktop.

Revisions

  1. thatryan created this gist Mar 27, 2020.
    12 changes: 12 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    location ~* ^(/.+)\.(jpg|jpeg|jpe|png|gif)$ {
    add_header Vary Accept;
    if ($http_accept ~* "webp"){
    set $imwebp A;
    }
    if (-f $request_filename.webp) {
    set $imwebp "${imwebp}B";
    }
    if ($imwebp = AB) {
    rewrite ^(.*) $1.webp;
    }
    }