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/

  • I believe you answer your own question with that link, just READ it)
    – alexus
    Mar 29, 2016 at 16:07
  • Haha. Well it says a lot. And I am not sure blindly adding it all is wise. Also I thought others could maybe benefit from the post ;)
    – snh_nl
    Mar 29, 2016 at 16:13
  • 1
    I wouldn't blindly add anything, I'd do backup and test it in non-production environment, then roll out changes to production environment.
    – alexus
    Mar 29, 2016 at 16:17

1 Answer 1


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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.