Mastering Nginx

(Ron) #1
Chapter 6

[ 149 ]

open_file_cache_valid 45s;

open_file_cache_min_uses 2;

open_file_cache_errors off;

}

# PDFs and powerpoint files handling.
location ~* ^.+\.(?:pdf|pptx?)$ {

expires 30d;

# Send everything all at once.
tcp_nodelay off;

}

Serving audio files exemplifies the use of AIO. The MP3 location is as follows:


# MP3 files are served using AIO where supported by the OS.
location ^~ /sites/default/files/audio/mp3 {

location ~* ^/sites/default/files/audio/mp3/.*\.mp3$ {

And Ogg/Vorbis location is as follows:


# Ogg/Vorbis files are served using AIO where supported by the
OS.
location ^~ /sites/default/files/audio/ogg {

location ~* ^/sites/default/files/audio/ogg/.*\.ogg$ {

These have the following lines in common:


directio 4k; # for XFS

tcp_nopush off;
aio on;
output_buffers 1 2M;
}

}
Free download pdf