From a61f03cfbf62eb006e6bd845694f18d40101d4e8 Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Sat, 29 Jun 2024 20:27:11 +1000 Subject: Added cache --- http.tcl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'http.tcl') diff --git a/http.tcl b/http.tcl index 68cb163..307aebf 100755 --- a/http.tcl +++ b/http.tcl @@ -103,13 +103,15 @@ namespace eval http { # Sends an opened file or cached file. proc send-file {channel filename} { - #TODO: configure it to try the cache. - #TODO: configure channels to use binary translation if content type is not text/* - set file [open $filename] - fconfigure $file -translation binary fconfigure $channel -translation binary - fcopy $file $channel - close $file + if [cache::hit $filename] { + puts $channel [cache::get $filename] + } else { + set file [open $filename] + fconfigure $file -translation binary + fcopy $file $channel + close $file + } } ## Header -- cgit v1.2.3