summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--globals.lisp4
-rwxr-xr-xjournal.lisp2
-rw-r--r--main.lisp2
-rw-r--r--mulk-journal.asd2
-rw-r--r--utils.lisp10
5 files changed, 19 insertions, 1 deletions
diff --git a/globals.lisp b/globals.lisp
index a609e63..1637931 100644
--- a/globals.lisp
+++ b/globals.lisp
@@ -76,3 +76,7 @@
"Warnings that should be displayed to the user.")
(defparameter *full-entry-view* t)
+
+(defparameter *site-root* nil)
+(defparameter *if-modified-since* nil)
+
diff --git a/journal.lisp b/journal.lisp
index cfac6fd..f1fd5b1 100755
--- a/journal.lisp
+++ b/journal.lisp
@@ -346,6 +346,7 @@
;;
;; (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date)))
(http-add-header "Content-Language" "de")
+ (http-add-header "Cache-Control" "public")
(http-send-headers "text/html; charset=UTF-8")
(<xhtml :xmlns "http://www.w3.org/1999/xhtml"
@@ -409,6 +410,7 @@
(defun show-web-journal ()
#.(locally-enable-sql-reader-syntax)
+ (revalidate-cache-or-die)
(with-web-journal ((if (member *action* '(:view :edit :preview :post-comment
:save-entry))
(title-of (find-entry *post-number*))
diff --git a/main.lisp b/main.lisp
index ae2c0cb..c8b489e 100644
--- a/main.lisp
+++ b/main.lisp
@@ -54,6 +54,8 @@
(*post-number* :view)
(t nil))))
(*method* (keywordify (gethash "REQUEST_METHOD" *http-env*)))
+ (*if-modified-since* #+clisp (ext:getenv "HTTP_IF_MODIFIED_SINCE")
+ #-clisp nil)
(*script-filename* (pathname-as-file
(or (gethash "SCRIPT_FILENAME" *http-env*)
"/home/mulk/Dokumente/Projekte/Mulkblog/journal.cgi")))
diff --git a/mulk-journal.asd b/mulk-journal.asd
index 6cd1da5..49a1e12 100644
--- a/mulk-journal.asd
+++ b/mulk-journal.asd
@@ -26,7 +26,7 @@
:depends-on (#:cl-ppcre #:cl-fad #:iterate #:cl-markdown #:parenscript
#:yaclml #:lisp-cgi-utils #:alexandria #:xml-emitter
#:split-sequence #:clsql #:clsql-uffi #:clsql-sqlite3
- #:drakma)
+ #:drakma #:cybertiggyr-time)
:components ((:file "defpackage")
(:file "macros")
(:file "globals")
diff --git a/utils.lisp b/utils.lisp
index 74030b8..590d310 100644
--- a/utils.lisp
+++ b/utils.lisp
@@ -325,3 +325,13 @@ ELEMENT-TYPE as the stream's."
(submitter-user-agent comment)
(spamp comment)
(body-of comment))))
+
+(defun revalidate-cache-or-die ()
+ #+clisp
+ (let ((time (cybertiggyr-time:parse-time *if-modified-since*)))
+ (when (and (integerp time) (>= *if-modified-since* (compute-journal-last-modified-date)))
+ (http-add-header "Status: 304 Not Modified")
+ (http-send-headers)
+ (ext:quit 0)))
+ #-clisp
+ nil)