From 173f9376ea5687c2bb5c6aad7faa5b58237dfa9c Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 26 Jun 2022 17:42:44 -0700 Subject: [PATCH] respect the setting of `setup:render-cache-active` for template caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit templates were being cached regardless of the value of `setup:render-cache-active` because its value wasn’t being tested --- pollen/private/ts.rktd | 2 +- pollen/render.rkt | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index 2faa8ba..ec90954 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1646354264 +1656290564 diff --git a/pollen/render.rkt b/pollen/render.rkt index c04cc61..862b70c 100644 --- a/pollen/render.rkt +++ b/pollen/render.rkt @@ -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)