#static-files
Posts
-
Digging into nginx's Source 10: Filters and Static Files — How a Response Flows Out
We follow one static file from the handler to the socket in the nginx 1.31.9 source. The static handler that never reads the file and only records "from this byte to that byte of the file" in an ngx_buf_t, the header and body filter chains glued together with two function pointers and the ngx_modules.c order that decides them, the copy filter and ngx_output_chain that decide whether to read the file into memory, and the write filter that holds data back and then sends it with writev + sendfile — all checked with gdb, strace and the debug log.
-
Digging into Apache httpd's Source 12: Handlers and Static Files — How a File Becomes a Response
How the "handler" set by SetHandler and AddHandler differs from the Content-Type, and how the core's default_handler() answers any request nobody else claimed by sending a single file bucket. We also check ETag and 304, Range and 206, the trailing-slash 301 and DirectoryIndex, and which system calls EnableSendfile and EnableMMAP actually change — with curl and strace.