add cache for static http server
This commit is contained in:
parent
51212e139a
commit
210eaade3a
1 changed files with 3 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
||||||
"_static_ext_server" net:http:server:register
|
"_static_ext_server" net:http:server:register
|
||||||
"_static_ext_Request" net:http:server:register
|
"_static_ext_Request" net:http:server:register
|
||||||
"bufsize" net:http:server:register
|
"bufsize" net:http:server:register
|
||||||
|
"client-cache" net:http:server:register
|
||||||
1024 net:http:server:=bufsize
|
1024 net:http:server:=bufsize
|
||||||
|
|
||||||
construct net:http:server:_static_ext_server {
|
construct net:http:server:_static_ext_server {
|
||||||
|
@ -27,7 +28,8 @@ construct net:http:server:_static_ext_Request {
|
||||||
filepath this:server:get-cached-files:get dup not if {
|
filepath this:server:get-cached-files:get dup not if {
|
||||||
pop filepath StreamTypes:file:create<0>:read-to-end<net:http:server:bufsize> dup this:server:cached-files:set;<filepath>
|
pop filepath StreamTypes:file:create<0>:read-to-end<net:http:server:bufsize> dup this:server:cached-files:set;<filepath>
|
||||||
}
|
}
|
||||||
this:write-ok:write-content-type<type>:write-body:finish;
|
def cache net:http:server:client-cache =cache
|
||||||
|
this:write-ok cache if { :write-header<"Cache-Control" "public, max-age=" cache _str concat> } :write-content-type<type>:write-body:finish;
|
||||||
}
|
}
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue