- fprintf(out, "HTTP/1.1 200 OK\n");
- fprintf(out, "Content-Type: %s\n", f.ctype);
- fprintf(out, "Content-Length: %zi\n", f.sz);
- fprintf(out, "Last-Modified: %s\n", fmthttpdate(f.mtime));
- fprintf(out, "\n");
- fwrite(f.data, 1, f.sz, out);
+ if(cached(req, f)) {
+ fprintf(out, "HTTP/1.1 304 Not Modified\n");
+ fprintf(out, "Content-Length: 0\n");
+ fprintf(out, "\n");
+ } else {
+ fprintf(out, "HTTP/1.1 200 OK\n");
+ fprintf(out, "Content-Type: %s\n", f.ctype);
+ fprintf(out, "Content-Length: %zi\n", f.sz);
+ fprintf(out, "Last-Modified: %s\n", fmthttpdate(f.mtime));
+ fprintf(out, "\n");
+ fwrite(f.data, 1, f.sz, out);
+ }