Skip to content

Improvement: Install brotli on custom nginx module #101

@lovestaco

Description

@lovestaco

Nginx is not supporting brotli module.

https://github.com/google/ngx_brotli

Hence we can't use a faster serving.

location ^~ /freedevtools/ {
    alias /tools/;

    # Cache headers
    expires 1y;
    add_header Cache-Control "public, max-age=31536000, immutable";
    add_header X-Content-Type-Options "nosniff";

    # 1. Brotli static (best compression)
    brotli on;
    brotli_static on;
    brotli_types text/plain text/css text/javascript application/javascript application/json application/xml application/xml+rss image/svg+xml text/html;

    # 2. Gzip fallback
    gzip on;
    gzip_static on;     # serve *.gz if present
    gzip_comp_level 6;
    gzip_min_length 1024;
    gzip_types
        text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml text/html;

    # 3. Correct try_files logic for static compressed files
    try_files $uri$br $uri$gz $uri =404;

    # Allow fonts cross-origin
    if ($uri ~ "\.(ttf|woff|woff2|eot)$") {
        add_header Access-Control-Allow-Origin "*";
        add_header Access-Control-Allow-Methods "GET, OPTIONS";
    }
}

Install the botli module via ansible.

Then try this configuration for a faster serve,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions