diff --git a/src/app.lisp b/src/app.lisp index 6e85b2e..0c4f79d 100644 --- a/src/app.lisp +++ b/src/app.lisp @@ -28,16 +28,6 @@ (defmethod jingle:process-response :around ((app (eql *page-app*)) result) (set-response-header :content-type "text/html; charset=utf-8") - (when (eq (request-method *request*) :get) - (let ((strategy (context :cache))) - (cond ((dev-mode-p) - (set-response-header :cache-control "private, no-store, must-revalidate")) - ((eq strategy :ssr) - (set-response-header :cache-control "public, max-age=0, must-revalidate")) - ((eq strategy :isr) - (set-response-header :cache-control "public, max-age=0, s-maxage=60, stale-while-revalidate=60")) - ((eq strategy :sg) - (set-response-header :cache-control "public, max-age=0, s-maxage=31536000, must-revalidate"))))) (call-next-method app (render-to-string (hsx (html :lang "en" diff --git a/src/helper.lisp b/src/helper.lisp index d2fe236..26b1d30 100644 --- a/src/helper.lisp +++ b/src/helper.lisp @@ -5,6 +5,8 @@ #:make-flexi-stream) (:import-from #:jonathan #:parse) + (:import-from #:website/lib/env + #:dev-mode-p) (:export #:request-body-json->plist #:set-metadata #:set-cache)) @@ -23,4 +25,11 @@ (setf (context :metadata) metadata)) (defun set-cache (strategy) - (setf (context :cache) strategy)) + (cond ((dev-mode-p) + (set-response-header :cache-control "private, no-store, must-revalidate")) + ((eq strategy :ssr) + (set-response-header :cache-control "public, max-age=0, must-revalidate")) + ((eq strategy :isr) + (set-response-header :cache-control "public, max-age=0, s-maxage=60, stale-while-revalidate=60")) + ((eq strategy :sg) + (set-response-header :cache-control "public, max-age=0, s-maxage=31536000, must-revalidate"))))