respect the setting of `setup:render-cache-active` for template caching

templates were being cached regardless of the value of `setup:render-cache-active` because its value wasn’t being tested
dev-gang-render
Matthew Butterick 3 years ago
parent d019908a93
commit 173f9376ea

@ -1 +1 @@
1646354264
1656290564

@ -481,7 +481,6 @@
[maybe-output-path]
[(->output-path source-path)]
[else #false]))
(define key (template-cache-key source-path output-path))
(define (cache-thunk)
(match source-path
[(or (? markup-source?) (? markdown-source?))
@ -495,13 +494,16 @@
get-fallback-template)])
(file-exists-or-has-source? (proc source-path output-path-ext)))]
[_ #false]))
(if (current-session-interactive?)
;; don't cache templates in interactive session, for fresher reloads
;; this makes it possible to add template and have it show up in next render
(cache-thunk)
;; otherwise, within a rendering session, this will prevent repeat players like "template.html.p"
;; from hitting the file cache repeatedly
(hash-ref! ram-cache key (λ () (cache-ref! key cache-thunk)))))
(cond
[(or (current-session-interactive?) (not (setup:render-cache-active source-path)))
;; don't cache templates in interactive session, for fresher reloads
;; this makes it possible to add template and have it show up in next render
(cache-thunk)]
;; otherwise, within a rendering session, this will prevent repeat players like "template.html.p"
;; from hitting the file cache repeatedly
[else
(define key (template-cache-key source-path output-path))
(hash-ref! ram-cache key (λ () (cache-ref! key cache-thunk)))]))
(module-test-external
(require pollen/setup sugar/file sugar/coerce)

Loading…
Cancel
Save