Changeset 500 in subversion


Ignore:
Timestamp:
Mar 1, 2007 3:40:00 PM (6 years ago)
Author:
thomasb
Message:

Solved wrong caching of message preview (#1484153, #1484236)

Location:
trunk/roundcubemail
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r498 r500  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42007/03/01 (thomasb) 
     5---------- 
     6- Solved page caching of message preview (closes #1484153) 
     7- Only use gzip compression if configured (closes #1484236) 
     8 
    39 
    4102007/02/25 (estadtherr) 
  • trunk/roundcubemail/index.php

    r414 r500  
    33 +-----------------------------------------------------------------------+ 
    44 | RoundCube Webmail IMAP Client                                         | 
    5  | Version 0.1-20061206                                                  | 
    6  |                                                                       | 
    7  | Copyright (C) 2005-2006, RoundCube Dev. - Switzerland                 | 
     5 | Version 0.1-20070301                                                  | 
     6 |                                                                       | 
     7 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
    88 | Licensed under the GNU GPL                                            | 
    99 |                                                                       | 
     
    4141*/ 
    4242 
    43 define('RCMAIL_VERSION', '0.1-20061206'); 
     43define('RCMAIL_VERSION', '0.1-20070301'); 
    4444 
    4545// define global vars 
     
    107107  { 
    108108  // use gzip compression if supported 
    109   if (function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) 
     109  if (function_exists('ob_gzhandler') && ini_get('zlib.output_compression')) 
    110110    ob_start('ob_gzhandler'); 
    111111  else 
  • trunk/roundcubemail/program/include/main.inc

    r491 r500  
    191191    } 
    192192 
    193   if (!$valid) 
    194     write_log('timeouts', 
    195       "REQUEST: " . var_export($_REQUEST, true) . 
    196       "\nEXPECTED: " . rcmail_auth_hash(session_id(), $_SESSION['auth_time']) . 
    197       "\nOR LAST: " . rcmail_auth_hash(session_id(), $_SESSION['last_auth']) . 
    198       "\nSESSION: " . var_export($_SESSION, true)); 
    199  
    200193  return $valid; 
    201194  } 
     
    560553    $_SESSION['user_lang'] = $sess_user_lang; 
    561554    $_SESSION['password']  = encrypt_passwd($pass); 
     555    $_SESSION['login_time'] = mktime(); 
    562556 
    563557    // force reloading complete list of subscribed mailboxes 
  • trunk/roundcubemail/program/include/rcube_shared.inc

    r497 r500  
    12171217 
    12181218// send header with expire date 30 days in future 
    1219 function send_future_expire_header() 
     1219function send_future_expire_header($offset=2600000) 
    12201220  { 
    12211221  if (headers_sent()) 
    12221222    return; 
    12231223 
    1224   header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+2600000)." GMT"); 
    1225   header("Cache-Control: "); 
     1224  header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+$offset)." GMT"); 
     1225  header("Cache-Control: max-age=$offset"); 
    12261226  header("Pragma: "); 
    12271227  } 
     1228 
     1229 
     1230// check request for If-Modified-Since and send an according response 
     1231function send_modified_header($mdate, $etag=null) 
     1232{ 
     1233  if (headers_sent()) 
     1234    return; 
     1235     
     1236  $iscached = false; 
     1237  if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate) 
     1238    $iscached = true; 
     1239   
     1240  $etag = $etag ? "\"$etag\"" : null; 
     1241  if ($etag && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) 
     1242    $iscached = true; 
     1243   
     1244  if ($iscached) 
     1245    header("HTTP/1.x 304 Not Modified"); 
     1246  else 
     1247    header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mdate)." GMT"); 
     1248   
     1249  header("Cache-Control: max-age=0"); 
     1250  header("Expires: "); 
     1251  header("Pragma: "); 
     1252   
     1253  if ($etag) 
     1254    header("Etag: $etag"); 
     1255   
     1256  if ($iscached) 
     1257    exit; 
     1258} 
    12281259 
    12291260 
  • trunk/roundcubemail/program/steps/mail/show.inc

    r483 r500  
    2424$PRINT_MODE = $_action=='print' ? TRUE : FALSE; 
    2525 
    26 // allow caching, unless remote images are present 
    27 if ((bool)get_input_value('_safe', RCUBE_INPUT_GET)) 
    28   send_nocacheing_headers(); 
    29 else 
    30   send_future_expire_header(); 
    31  
    3226// similar code as in program/steps/mail/get.inc 
    3327if ($_GET['_uid']) 
     
    3529  $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET)); 
    3630  $MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']); 
    37   $MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']); 
    3831   
    3932  // go back to list if message not found (wrong UID) 
    40   if (!$MESSAGE['headers'] || !$MESSAGE['structure']) 
     33  if (!$MESSAGE['headers']) 
    4134    { 
    4235    show_message('messageopenerror', 'error'); 
     
    5043    } 
    5144 
     45  // calculate Etag for this request 
     46  $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().($PRINT_MODE?1:0)); 
     47 
     48  // allow caching, unless remote images are present 
     49  if ((bool)get_input_value('_safe', RCUBE_INPUT_GET)) 
     50    send_nocacheing_headers(); 
     51  else 
     52    send_modified_header($_SESSION['login_time'], $etag); 
     53 
     54 
    5255  $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); 
    5356   
    54   if ($MESSAGE['structure']) 
     57  if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID'])) 
    5558    list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message( 
    5659      $MESSAGE['structure'], 
Note: See TracChangeset for help on using the changeset viewer.