From ae1617c3ff0ebca9310455fd2c54736f62df9fbf Mon Sep 17 00:00:00 2001 From: thomasb Date: Thu, 1 Mar 2007 20:40:00 +0000 Subject: Solved wrong caching of message preview (#1484153, #1484236) git-svn-id: https://svn.roundcube.net/trunk@500 208e9e7b-5314-0410-a742-e7e81cd9613c --- roundcubemail/program/include/rcube_shared.inc | 37 +++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'roundcubemail/program/include/rcube_shared.inc') diff --git a/roundcubemail/program/include/rcube_shared.inc b/roundcubemail/program/include/rcube_shared.inc index ba63c825f..558fbf7d9 100644 --- a/roundcubemail/program/include/rcube_shared.inc +++ b/roundcubemail/program/include/rcube_shared.inc @@ -1216,17 +1216,48 @@ function send_nocacheing_headers() // send header with expire date 30 days in future -function send_future_expire_header() +function send_future_expire_header($offset=2600000) { if (headers_sent()) return; - header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+2600000)." GMT"); - header("Cache-Control: "); + header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+$offset)." GMT"); + header("Cache-Control: max-age=$offset"); header("Pragma: "); } +// check request for If-Modified-Since and send an according response +function send_modified_header($mdate, $etag=null) +{ + if (headers_sent()) + return; + + $iscached = false; + if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate) + $iscached = true; + + $etag = $etag ? "\"$etag\"" : null; + if ($etag && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) + $iscached = true; + + if ($iscached) + header("HTTP/1.x 304 Not Modified"); + else + header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mdate)." GMT"); + + header("Cache-Control: max-age=0"); + header("Expires: "); + header("Pragma: "); + + if ($etag) + header("Etag: $etag"); + + if ($iscached) + exit; +} + + // function to convert an array to a javascript array function array2js($arr, $type='') { -- cgit v1.2.3