Pomiar obciążenia serwera przez cache

Wszystko o językach skryptowych takich jak PHP i Perl, serwerach WWW, CGI, bazach danych i języku SQL.
cysioland
Posty: 206
Rejestracja: 14 lut 2009, 21:18:54
Strona na CBA.pl: http://computer-planet.cba.pl
Lokalizacja: Krapkowice
Płeć: Mężczyzna
User Agent: Opera Windows 1024x768
Kontakt:

Pomiar obciążenia serwera przez cache

Post autor: cysioland »

Witam,
Mam problem. Jak sprawdzić,czy cache zapisujące zawartość strony do pliku mniej obciąża serwer,niż odczytanie pliku?

kod pliku:

Kod: Zaznacz cały

<?php
session_name('takaktorejniepodam');
session_start();
include('config.php');
include('functions.php');
cache_start(500, 'index');
echo '
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Grimoth MMOSG</title>
<style type="text/css">
body{background-color: #EEEEEE}
div#projects{display: none}
div#header{text-align: center}
div#content{float: left}
div#right{float: right}
div#footer{clear: both;text-align: center}
</style>
</head>
<body>
<div id="projects">
Inne projekty:
</div>
<div id="header">
<h1>Grimoth - gra MMOSG osadzona w roku 3000.</h1>
</div>
<div id="wrapper">
<div id="content">
Grimoth to gra osadzona w roku 3000.
</div>
<div id="right">
Coś z prawej
</div>
</div>
<div id="footer">
Stopka
</div>
</body>
</html>';
cache_end('index');
?>
Kod functions.php:

Kod: Zaznacz cały

<?php
function cache_start($age,$file_name){
    global $cache_file; 
     $cache_file = "cache/". $file_name . ".dat";
     $cachetime = $age;
     if (file_exists($cache_file) && (time() - $cachetime < filemtime($cache_file))){
        include($cache_file);
        exit;
     }
    ob_start();
}
function cache_end($file_name){
    $cache_file = "cache/". $file_name . ".dat";
     $fp = fopen($cache_file, 'w'); 
     fwrite($fp, ob_get_contents());
     fclose($fp);
     ob_end_flush();
}
?> 
I jeszcze wyjaśnienie: nie testuję tego na cba.pl

Pomocy,
Cysioland
piotrrydz
Posty: 2
Rejestracja: 05 mar 2015, 12:52:15
Płeć: Niewybrana
User Agent: Safari Windows
Kontakt:

Re: Pomiar obciążenia serwera przez cache

Post autor: piotrrydz »

dołączam się do pytania
ODPOWIEDZ