/** * This is a placeholder for future development. * * @param string content-type; override for RSS feeds * @param integer seconds * @param string charset * @param boolean flush already collected content from the PageCache */ function headers_content_mightcache($type = 'text/html', $max_age = '#', $charset = '#', $flush_pagecache = true) { global $Messages, $is_admin_page; global $PageCache, $Debuglog; header_content_type($type, $charset); if (empty($max_age) || $is_admin_page || is_logged_in() || $Messages->count()) { // Don't cache if no max_age given // + NEVER EVER allow admin pages to cache // + NEVER EVER allow logged in data to be cached // + NEVER EVER allow transactional Messages to be cached!: header_nocache(); // Check server caching too, but note that this is a different caching process then caching on the client // It's important that this is a double security check only and server caching should be prevented before this // If something should not be cached on the client, it should never be cached on the server either if (!empty($PageCache)) { // Abort PageCache collect $Debuglog->add('Abort server caching in headers_content_mightcache() function. This should have been prevented!'); $PageCache->abort_collect($flush_pagecache); } return; } // If we are on a "normal" page, we may, under some circumstances, tell the browser it can cache the data. // This MAY be extremely confusing though, every time a user logs in and gets back to a screen with no evobar! // This cannot be enabled by default and requires admin switches. // For feeds, it is a little bit less confusing. We might want to have the param enabled by default in that case. // WARNING: extra special care needs to be taken before ever caching a blog page that might contain a form or a comment preview // having user details cached would be extremely bad. // in the meantime... header_nocache(); }
/** * 输出客服操作页面页头 s_page_header */ protected function s_page_header($path = '') { header_nocache(); //不缓存 echo '<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <title>' . APP::$_CFG['Title'] . '</title> <link rel="shortcut icon" href="' . SYSDIR . 'public/img/favicon.ico" type="image/x-icon"> <link rel="stylesheet" type="text/css" href="' . SYSDIR . 'public/admin.css"> <link rel="stylesheet" type="text/css" href="' . SYSDIR . 'public/easyDialog/easyDialog.css"> <link rel="stylesheet" type="text/css" href="' . SYSDIR . 'public/jquery.tipTip.css"> <script src="' . SYSDIR . 'public/jquery191.js" type="text/javascript"></script> <script src="' . SYSDIR . 'public/jquery.tipTip.js" type="text/javascript"></script> <script src="' . SYSDIR . 'public/jquery.scrollbar.js" type="text/javascript"></script> <script src="' . SYSDIR . 'public/support.js" type="text/javascript"></script> <script type="text/javascript"> var this_uri = "' . strstr($_SERVER['REQUEST_URI'], 'index.php') . '", BASEURL = "' . BASEURL . '", SYSDIR = "' . SYSDIR . '", WS_HOST = "' . WS_HOST . '", WS_PORT = "' . WS_PORT . '", update_time = ' . ForceInt(APP::$_CFG['Update']) . ', admin ={id: ' . $this->admin['aid'] . ', type: ' . $this->admin['type'] . ', sid: "' . $this->admin['sid'] . '", fullname: "' . $this->admin['fullname'] . '", post: "' . $this->admin['post'] . '", agent: "' . $this->admin['agent'] . '"}; </script> </head> <body class="online"> <script src="' . SYSDIR . 'public/easyDialog/easyDialog.js" type="text/javascript"></script> ' . $this->s_header_menu($path, 1) . ' <div class="maindiv"> <div id="main">'; }
GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: Remi Collet // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); if (!isset($_POST["id"])) { exit; } if (!isset($_REQUEST['glpi_tab'])) { exit; } ajaxFooter();
/** * Print a nice HTML head with no controls * * @param $title title of the page * @param $url not used anymore. **/ function nullHeader($title, $url = '') { global $CFG_GLPI, $HEADER_LOADED, $LANG; if ($HEADER_LOADED) { return; } $HEADER_LOADED = true; // Print a nice HTML-head with no controls // Detect root_doc in case of error Config::detectRootDoc(); // Send UTF8 Headers header("Content-Type: text/html; charset=UTF-8"); // Send extra expires header if configured header_nocache(); if (isCommandLine()) { return true; } includeCommonHtmlHeader($title); // Body with configured stuff echo "<body>"; echo "<div id='page'>"; echo "<div id='bloc'>"; echo "<div class='haut'></div>"; }
/** * Retrieve and output cache for current URL. * * @return boolean true if we could retrieve */ function retrieve() { global $Debuglog; global $ReqURL; global $servertimenow; global $Timer; global $Settings; // What would be the cache file for the current URL? $af_cache_file = $this->get_af_filecache_path(); /* // fstat() is interesting because it gives the last access time... use that for purging... * Tblue> Note: Many server admins mount partitions with the "noatime" * option, which disables atime updates and thus speeds * up disk access - that means the atime is not reliable, * better use the mtime (modification time). if( $fh = @fopen( $af_cache_file, 'r', false ) ) { $fstat = fstat( $fh ); pre_dump( $fstat ); fclose( $fh ); } */ $Timer->resume('Read cache file'); $lines = @file($af_cache_file, false); $Timer->pause('Read cache file'); if ($this->cache_Blog != NULL) { $last_invalidation_timestamp = $this->cache_Blog->get_setting('last_invalidation_timestamp'); if ($last_invalidation_timestamp == 0) { $this->cache_Blog->set_setting('last_invalidation_timestamp', $servertimenow); $this->cache_Blog->dbupdate(); } } else { $last_invalidation_timestamp = $Settings->get('last_invalidation_timestamp'); if ($last_invalidation_timestamp == 0) { $Settings->set('last_invalidation_timestamp', $servertimenow); $Settings->dbupdate(); } } // fp> note we are using empty() so that we detect both the case where there is no file and the case where the file // might have ended up empty because PHP crashed while writing to it or sth like that... if (!empty($lines)) { // We have data in the cache! $Debuglog->add('Retrieving from cache!', 'pagecache'); $Timer->resume('Cache file processing'); // Retrieved cached URL: $retrieved_url = trim($lines[0]); unset($lines[0]); if ($retrieved_url != $ReqURL) { $Debuglog->add('Cached file URL [' . $retrieved_url . '] does not match current URL, aborting retrieve.', 'pagecache'); return false; } // timestamp of cache generation: $retrieved_ts = trim($lines[1]); unset($lines[1]); $cache_age = $servertimenow - $retrieved_ts; $Debuglog->add('Cache age: ' . floor($cache_age / 60) . ' min ' . $cache_age % 60 . ' sec', 'pagecache'); if ($cache_age > $this->max_age_seconds || $last_invalidation_timestamp > $retrieved_ts) { // Cache has expired return false; } $i = 1; $optional_headers = array(); // Go through optional header lines // Optional headers are separated from the file header with an empty line. while ($optional_header_line = trim($lines[++$i])) { // All optional header name value must be separated with ':' if (strpos($optional_header_line, ':') === false) { $Debuglog->add('Cached file format not recognized, aborting retrieve.', 'pagecache'); return false; } list($header_name, $header_value) = explode(":", $optional_header_line); // Optional header name and value must not be empty $header_name = trim($header_name); $header_value = trim($header_value); if (empty($header_name) || empty($header_value)) { $Debuglog->add('Cached file format not recognized, aborting retrieve.', 'pagecache'); return false; } $optional_headers[$header_name] = $header_value; unset($lines[$i]); } // unset the empty line unset($lines[$i]); // count item views happening on this page: if (isset($optional_headers['item_IDs_on_this_page'])) { global $shutdown_count_item_views; $shutdown_count_item_views = explode(',', $optional_headers['item_IDs_on_this_page']); } // Check if the request has an If-Modified-Since date if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { $if_modified_since = strtotime(preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE'])); if ($retrieved_ts <= $if_modified_since) { // Cached version is equal to (or older than) $if_modified since; contents probably not modified... // It is still possible that in between we have sent logged-in versions (including evobar) of the page // and that the browser has an evobar version of the page in cache. Let's verify this before sending a 304... // We do this with an ETag header (another solution may be the Vary header) if (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) { $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH']; // pre_dump($if_none_match, gen_current_page_etag() ); if ($if_none_match == gen_current_page_etag()) { // Ok, this seems to be really the same: header_http_response('304 Not Modified'); exit(0); } } } } // Page was modified, revert $shutdown_count_item_views set $shutdown_count_item_views = array(); // ============== Ready to send cached version of the page ================= // Send no cache header including last modified date: header_nocache($retrieved_ts); // Go through headers that were saved in the cache: // $i was already set while ($headerline = trim($lines[++$i])) { header($headerline); unset($lines[$i]); } unset($lines[$i]); // SEND CONTENT! $body = implode('', $lines); $Timer->pause('Cache file processing'); $Timer->resume('Sending cached content'); // Echo a first chunk (see explanation below) $buffer_size = 12000; // Empiric value, you can make it smaller if you show me screenshots of better timings with a smaller value echo substr($body, 0, $buffer_size); ob_start(); // fp> So why do we want an ob_start here? // fp> Because otherwise echo will "hang" until all the data gets passed through apache (on default Apache install with default SendBufferSize) // fp> With ob_start() the script will terminate much faster and the total exec time of the script will look much smaller. // fp> This doesn't actually improve the speed of the transmission, it just lets the PHP script exit earlier // fp> DRAWBACK: shutdown will be executed *before* the "ob" data is actually sent :'( // fp> This is why we send a first chunk of data before ob_start(). shutdown can occur while that data is sent. then the remainder is sent. // Inspiration: http://wonko.com/post/seeing_poor_performance_using_phps_echo_statement_heres_why // http://fplanque.com/dev/linux/how-to-log-request-processing-times-in-apache // http://fplanque.com/dev/linux/why-echo-is-slow-in-php-how-to-make-it-really-fast // fp> TODO: do something similar during page cache collection. echo substr($body, $buffer_size); // ob_end_flush(); // fp> WARNING: Putting an end flush here would just kill the benefit of the ob_start() above. $Timer->pause('Sending cached content'); return true; } return false; }
public function __construct($path) { parent::__construct($path); header_nocache(); //不缓存 }