diff --git a/examples/sendfile/sendfile.zig b/examples/sendfile/sendfile.zig index 2fbb448..daf16dd 100644 --- a/examples/sendfile/sendfile.zig +++ b/examples/sendfile/sendfile.zig @@ -17,6 +17,9 @@ pub fn on_request(r: zap.SimpleRequest) void { // On error, the handle will still be valid and should be used to send an error response // // Important: sets last-modified and cache-control headers with a max-age value of 1 hour! + + // In this example, we disable caching + r.setHeader("Cache-Control", "no-cache") catch unreachable; if (r.sendFile("examples/sendfile/testfile.txt")) {} else |err| { std.log.err("Unable to send file: {any}", .{err}); } diff --git a/src/zap.zig b/src/zap.zig index 96cd5df..6bea777 100644 --- a/src/zap.zig +++ b/src/zap.zig @@ -182,6 +182,7 @@ pub const SimpleRequest = struct { /// On error, the handle will still be valid and should be used to send an error response /// /// Important: sets last-modified and cache-control headers with a max-age value of 1 hour! + /// You can override that by setting those headers yourself, e.g.: setHeader("Cache-Control", "no-cache") pub fn sendFile(self: *const Self, file_path: []const u8) !void { if (fio.http_sendfile2(self.h, util.toCharPtr(file_path), file_path.len, null, 0) != 0) return error.SendFile;