Pular para conteúdo

$browser_engine

The $browser_engine variable holds the rendering engine used by the client's browser. It is set by the device-type module when a request is processed, based on the User-Agent string or Client Hints.

Type

string

Possible values

  • Blink: Used by browsers like Google Chrome and Opera.
  • Gecko: Used by Mozilla Firefox.
  • WebKit: Used by Safari and older versions of Chrome.

Examples

Log the Browser Engine

To log the browser engine used by clients, you can include $browser_engine in your log_format.

http {
    log_format main '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent" '
                    '"$browser_engine"';

    access_log /var/log/nginx/access.log main;
}

Add a Header with the Browser Engine

You can add a custom header to pass the browser engine information to your backend or for debugging purposes.

location / {
    add_header X-Browser-Engine $browser_engine;
    proxy_pass http://backend;
}

Vary Cache Key by Browser Engine

To cache different versions of content based on the browser engine, include $browser_engine in your proxy_cache_key.

location / {
    proxy_cache_key "$scheme$request_uri|$browser_engine";
    proxy_pass http://backend;
}