diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2024-06-29 20:27:11 +1000 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2024-06-29 20:27:11 +1000 |
commit | a61f03cfbf62eb006e6bd845694f18d40101d4e8 (patch) | |
tree | 30c7a00c956e61ed2c54c4893cb449eae5bf55da /http.tcl | |
parent | 252ad2b3446457e95fb7bb41829bc24304090232 (diff) |
Added cache
Diffstat (limited to 'http.tcl')
-rwxr-xr-x | http.tcl | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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 |