Skip to content

Commit 66994f2

Browse files
committed
Debug add env var LEARNOCAML_SERVER_NOCACHE to disable all http caching
1 parent 2ac5c54 commit 66994f2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ testrun: build install
5757
learn-ocaml build --repo $(REPO) -j1
5858
rm -rf www/css
5959
ln -s ../static/css www
60-
learn-ocaml serve
60+
LEARNOCAML_SERVER_NOCACHE=1 learn-ocaml serve
6161

6262
docker-images: Dockerfile learn-ocaml.opam
6363
@rm -rf docker

src/server/learnocaml_server.ml

+8-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ type 'a response =
8686

8787
type error = (Cohttp.Code.status_code * string)
8888

89-
let caching: type resp. resp Api.request -> caching = function
89+
let disable_cache =
90+
match Sys.getenv_opt "LEARNOCAML_SERVER_NOCACHE" with
91+
| None | Some ("" | "0" | "false") -> false
92+
| Some _ -> true
93+
94+
let caching: type resp. resp Api.request -> caching = fun resp ->
95+
if disable_cache then Nocache else
96+
match resp with
9097
| Api.Version () -> Shortcache (Some ["version"; "server_id"])
9198
| Api.Static ("fonts"::_ | "icons"::_ | "js"::_::_::_ as p) -> Longcache p
9299
| Api.Static ("css"::_ | "js"::_ | _ as p) -> Shortcache (Some p)

0 commit comments

Comments
 (0)