6 This plugin implements some speed-ups for the HTTP protocol (used by
7 most proxies and all browsers maintaining their own cache). The
8 rendering of the current page will then be aborted, if this plugin
9 detects it is unnecessary, because a client told so.
11 It can compare against "ETags" and "Last-Modified" values, and aborts
12 further ewiki processing early, if one of these conditions matches, and
13 also terminates ewiki for HEAD method requests (because no output is
16 This will only take effect, if you disable EWIKI_NOCACHE (set it to 0).
17 (Should we output the "*: no-cache" headers conditionally? - how?)
22 $ewiki_plugins["handler"][] = "ewiki_speed_abort";
26 function ewiki_speed_abort($id, &$data, $action) {
28 $o = ""; // unused here
34 if (($if=$_SERVER["HTTP_IF_MATCH"]) || ($if=$_SERVER["HTTP_IF_NONE_MATCH"]) && ($inverse=1) ) {
37 and ($etag = ewiki_etag($data))
38 or ($etag = "never:matching:".time());
40 #-- walk through comparison values
41 foreach (explode(",", $if) as $match) {
42 $match = trim(trim($match), '"');
43 if (($match == "*") || ($match == $etag)) {
51 #-- check against modification time
52 if (($if=$_SERVER["HTTP_IF_MODIFIED_SINCE"]) || ($if=$_SERVER["HTTP_IF_UNMODIFIED_SINCE"]) && ($inverse=1)) {
54 ($modif = $data["lastmodified"])
55 or ($modif = UNIX_MILLENNIUM);
57 $if = strtotime(trim($if));
69 #-- abort ewiki rendering, if matched or senseful to do so
70 if ($yes || ($_SERVER["REQUEST_METHOD"] == "HEAD")) {
72 #ewiki_http_headers($o, $id, $data, $action);
73 (It was probably bad to send the ETag and Content-Version fields
74 for this http answer?)
76 header("Status: 304 Not Modified");
80 if (!$inverse || ($_SERVER["REQUEST_METHOD"]!="GET")) {
81 header("Status: 412 Precondition Failed");