Improve set-cache
This commit is contained in:
parent
96e7dadfdf
commit
361c87d6f0
2 changed files with 10 additions and 11 deletions
10
src/app.lisp
10
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"
|
||||
|
|
|
@ -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"))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue