Giter VIP home page Giter VIP logo

webp-detect's Introduction

WebP with Accept negotiation

A collection of configuration scripts for serving WebP assets:

  • Check if the client advertises "image/webp" in Accept header
  • If WebP is supported, check if the local WebP file is on disk, and serve it
  • If server is configured as proxy, append a "WebP: true" header and forward to backend
  • Append "Vary: Accept" to the client response

Above sequence of steps allows transparent Accept negotiation of WebP assets - no need to modify your existing applications. Either pregenerate the WebP files, or serve WebP files dynamically to approriate clients.

Getting started

Download or copy the configuration file and run your server. For example:

$> nginx -c /path-to/webp-detect/nginx.conf
$> varnishd -a :8081 -T localhost:6082 -F -f varnish.vcl

With the above in place, access the page and look at the request header appended by the server - you will see a new WebP header sent to your application server if the browser supports WebP.

What about server X?

webp-detect's People

Contributors

igrigorik avatar msemenistyi avatar uhop avatar watermelonjuice avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.