Skip to content

early hints question and feature request in equal time #763

Open
@osevan

Description

@osevan

according nginx

we need to set this map and early_hints $early_hints; directive inside server function.

map $http_sec_fetch_mode $early_hints { 
        navigate $http2$http3; 
}
server  { 
        ... 
        location / { 
             early_hints $early_hints;
             proxy_pass http://example.com; 
        }
}

but i have critical question: we need to set extra early hints headers like this one?
according this
is this true?

 early_hints {
            add_header Link "</styles.css>; rel=preload; as=style";
            add_header Link "</scripts.js>; rel=preload; as=script";
            add_header Link "</logo.png>; rel=preload; as=image";
            add_header Link "</font.woff2>; rel=preload; as=font";
        }

If yes, we need a better option, like the one above, because no one—especially tech admins—knows which resources need to be loaded first or what their filenames are. This is especially difficult since many pages are constantly changing and require manual adjustments, which is not the right approach for enabling performance features like this.

When someone edits a blog or a normal website, having the server admin manually adjust the Early Hints feature is not a smart solution.

ENHANCED VERSION FEATURE REQUEST:

example user have fastcgi_cache

map $http_sec_fetch_mode $early_hints {
    navigate $http2$http3;  
}


fastcgi_cache_path /var/cache/nginx/fastcgi_cache levels=1:2 keys_zone=fastcgi_cache:10m max_size=1g inactive=60m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

server {
    listen 80;

    
    location / {
        fastcgi_cache fastcgi_cache;
        fastcgi_cache_valid 200 301 302 10m;
        fastcgi_cache_valid 404 1m;
        fastcgi_cache_bypass $cookie_nocache $arg_nocache$http_pragma;

       ######## this should be do everything automatically i mean with this recognizing every resource from side after first run - learning mode - done.
        early_hints $early_hints;

        
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
        include fastcgi_params;

        
        location ~* \.(jpg|jpeg|gif|png|css|js|svg)$ {
            expires 30d;
            add_header Cache-Control "public, no-store";
        }
    }
}

enhanced version will be first get request early hints should be learned with every style.css ,script.js logo.webp,png,jpg and fonts needed and than do automatically header setting dynamically.

thanks and

best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions