X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=news.php;h=6eb78e63efe9e10ff3258fb9c7f3407d4b8b59bb;hp=b729bb7f046f955844ea7100302214d29f8b406b;hb=41c341624c16607ac710aac446cc0ead3c53671b;hpb=9acc365249b5e630da6b5cdd23e3a8015f39ddc7 diff --git a/news.php b/news.php index b729bb7..6eb78e6 100644 --- a/news.php +++ b/news.php @@ -6,8 +6,20 @@ require_once ("./inc/settings.php"); require_once ("./inc/db/mysql.php"); require_once ("./inc/utils.php"); -header ("Content-type: application/atom+xml; charset=UTF-8"); -header("Cache-control: no-cache"); +function headers_callback ($output) { + $etag = md5 ($output); + if ((isset ($_SERVER ["HTTP_IF_NONE_MATCH"])) && + ($_SERVER ["HTTP_IF_NONE_MATCH"] == $etag)) { + header ("HTTP/1.1 304 Not Modified"); + exit (); + } + + header ("Content-type: application/atom+xml; charset=UTF-8"); + header ("Cache-control: must-revalidate"); + header (sprintf ("ETag: %s", $etag)); + + return $output; +} function date3339 ($feature) { $date = date ('Y-m-d\TH:i:s', $feature->date); @@ -118,5 +130,8 @@ try { } catch (Exception $e) { exit ("server error"); } + +ob_start ("headers_callback"); main ($features); +ob_end_flush () ?>