Nginx – Speed: nginx serving static content even faster: fixed folder ; how can I

centosnginxperformance

we run centos and nginx one of latest versions in 2016. We use 1 media directory with some underlying subdirectories. FTTB for php is 200ms which is very fast – but now I discovered that the JS CSS and JPG statis content also has 200ms FTTB (download is fast at only 30ms) ….

question: what is a working nginx directive so we can optimze our nginx config for the statis content? (so files are served insanely fast)

Currently all files are on the same server as the mother php file. But I don't believe a CDN makes a lot of difference. Or would it?

help appreciated


location /media {
fttb = super_fast;
}

References I found:
https://www.nginx.com/resources/admin-guide/serving-static-content/

Best Answer

This is our solution so far - but it looks like our server was already configured for speed. Improvements are welcome.

location ~ ^/(media).* {
    access_log          off;
    log_not_found       off;
    server_tokens       off;
    autoindex           off;
    sendfile            on;
    sendfile_max_chunk  1m;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    add_header          Cache-Control public;
    gzip_static         on;
    gzip_min_length     1000;
    gzip_comp_level     2;
    expires             max;
    fastcgi_hide_header Set-Cookie;
}