Disable preload and cache when in dev-mode
This commit is contained in:
parent
adbf730cf7
commit
fdad470f0e
2 changed files with 11 additions and 3 deletions
src
|
@ -5,7 +5,8 @@
|
|||
(:export #:website-env
|
||||
#:website-url
|
||||
#:microcms-service-domain
|
||||
#:microcms-api-key))
|
||||
#:microcms-api-key
|
||||
#:dev-mode-p))
|
||||
(in-package #:website/lib/env)
|
||||
|
||||
(load-env (merge-pathnames "./.env"))
|
||||
|
@ -19,3 +20,6 @@
|
|||
(env-var microcms-service-domain "MICROCMS_SERVICE_DOMAIN")
|
||||
(env-var microcms-api-key "MICROCMS_API_KEY")
|
||||
(env-var microcms-webhook-key "MICROCMS_WEBHOOK_KEY")
|
||||
|
||||
(defun dev-mode-p ()
|
||||
(string= (website-env) "dev"))
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#:jingle)
|
||||
(:import-from #:jonathan
|
||||
#:to-json)
|
||||
(:import-from #:website/lib/env
|
||||
#:dev-mode-p)
|
||||
(:import-from #:website/helper
|
||||
#:api-request-p)
|
||||
(:import-from #:website/components/metadata
|
||||
|
@ -16,7 +18,7 @@
|
|||
|
||||
(defmethod jingle:process-response :around ((app jingle:app) result)
|
||||
(when (eq (request-method *request*) :get)
|
||||
(if (context :no-cache)
|
||||
(if (or (context :no-cache) (dev-mode-p))
|
||||
(set-response-header :cache-control "private, no-store, must-revalidate")
|
||||
(set-response-header :cache-control "public, max-age=60")))
|
||||
(cond ((api-request-p)
|
||||
|
@ -31,7 +33,9 @@
|
|||
(~metadata :metadata (context :metadata))
|
||||
(~scripts))
|
||||
(body
|
||||
:hx-ext "head-support, response-targets, preload"
|
||||
:hx-ext (<>
|
||||
"head-support, response-targets, "
|
||||
(and (not (dev-mode-p)) "preload"))
|
||||
:hx-boost "true" :hx-swap "transition:true"
|
||||
:hx-target-404 "body" :hx-target-5* "body"
|
||||
(~layout result)))))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue