*** empty log message ***

svn path=/trunk/boinc/; revision=3946
This commit is contained in:
Eric J. Korpela 2004-07-23 04:04:21 +00:00
parent 2e120bb4a8
commit 1ca61ba699
12 changed files with 97 additions and 13 deletions

View File

@ -15463,7 +15463,7 @@ Rom July 19 2004
- Tag for 4.01 release, all platforms
boinc_release_4_01
Eric
Eric K. July 20 2004
- Added cache control headers to the cached php pages to reduce CGI
load on the web server. The headers include Last-Modified, Expires,
and Cache-Control: public, max-age=. Expiration and max-age are
@ -15474,6 +15474,10 @@ Eric
html/inc/cache.inc
Rom July 19 2004
- Fix a bug where during the benchmarking process all the active tasks
would die off.
@ -15631,3 +15635,32 @@ Jeff 22 July 2004
db/
boinc_db.C
Eric K. July 22 2004
- Worked a bit more on the caching... Improvements include....
- A parameter file html/project.sample/cache_parameters.inc that
contains the cache TTL values for differing types of files, maximum
cache size and minimum free disk space in the cache directory.
- Reducing the cache TTL to 0 for a specific file type results in
caching being turned off for that file type.
- The cache now has 256 subdirectories to speed up file open times.
- The cache directories will be automatically built if they don't exist
when first called
- The cache size is checked every CACHE_SIZE_CHECK_FREQ page accesses.
If the max size or min free space are exceeded, file are purged in
order of age until the cache size is below the cutoff.
html/
inc/
cache.inc
profile.inc
project.sample/
cache_parameters.inc
user/
download.php
hosts_user.php
sample_index.php
show_user.php
team_display.php
top_hosts.php
top_teams.php
top_users.php

View File

@ -27,9 +27,50 @@ function get_path($params) {
return $path;
}
function disk_usage($dir) {
$usage=0;
if ($handle=@opendir($dir)) {
while ($file=readdir($handle)) {
if (($file != ".") && ($file != "..")) {
if (@is_dir($dir."/".$file)) {
$usage+=disk_usage($dir."/".$file);
} else {
$usage+=@filesize($dir."/".$file);
}
}
}
@closedir($handle);
}
return $usage;
}
function clean_cache($max_age,$dir="../cache") {
if ($handle=@opendir($dir)) {
while ($file=readdir($handle)) {
if (($file != ".") && ($file != "..")) {
if (@is_dir($dir."/".$file)) {
clean_cache($max_age,$dir."/".$file);
} else {
if ((time()-@filemtime($file))>$max_age) @unlink($file);
}
}
}
@closedir($handle);
}
}
function start_cache($max_age, $params=""){
$path = get_path($params);
// check free disk space every once in a while
if (!(rand() % CACHE_SIZE_CHECK_FREQ)) {
$too_old=86400;
while ((disk_free_space("../cache") < MIN_FREE_SPACE) ||
(disk_usage("../cache") > MAX_CACHE_USAGE)) {
clean_cache($too_old);
$too_old/=2;
}
}
if ($max_age) {
$path = get_path($params);
$request = getallheaders();
// Check to see if this is a conditional fetch.
$lastmodified = @filemtime($path);

View File

@ -462,7 +462,7 @@ function show_profile($userid, $verify_mode=false) {
if (!$verify_mode) {
page_tail();
}
if ($caching) end_cache($cache_args);
if ($caching) end_cache(USER_PROFILE_TTL,$cache_args);
}
function show_profile_summary($user, $profile, $can_edit, $verify_mode) {

View File

@ -1,11 +1,21 @@
<?php
// This file defines the lifetime of public php pages
// Define the lifetime of public php pages.
// define to zero to turn of caching for these pages.
define('TEAM_PAGE_TTL',3600);
define('USER_PAGE_TTL',3600);
define('USER_HOST_TTL',3600);
define('USER_PROFILE_TTL',3600);
define('TOP_PAGES_TTL',43200);
define('DOWNLOAD_PAGE_TTL',3600);
define('INDEX_PAGE_TTL',3600);
// Define the max allowed cache usage and the min allowed free space
// Both default to 100M.
define('MAX_CACHE_USAGE',104857600);
define('MIN_FREE_SPACE',104857600);
// Number of page views between cache size checks
define('CACHE_SIZE_CHECK_FREQ',1000);
?>

View File

@ -52,5 +52,5 @@ require_once("../inc/download.inc");
</font>
";
page_tail();
end_cache();
end_cache(DOWNLOAD_PAGE_TTL);
?>

View File

@ -21,7 +21,7 @@
user_host_table_start(false);
} else {
echo "Hidden\n";
end_cache($cache_args);
end_cache(USER_PAGE_TTL,$cache_args);
exit();
}
$private = false;
@ -42,5 +42,5 @@
mysql_free_result($result);
echo "</table>\n";
page_tail();
if ($caching) end_cache($cache_args);
if ($caching) end_cache(USER_PAGE_TTL,$cache_args);
?>

View File

@ -111,5 +111,5 @@ echo "-->\n";
page_tail(true);
//end_cache();
//end_cache(INDEX_PAGE_TTL);
?>

View File

@ -38,5 +38,5 @@
page_tail();
}
}
end_cache($cache_args);
end_cache(USER_PAGE_TTL,$cache_args);
?>

View File

@ -35,6 +35,6 @@ if (!$team) {
display_team_page($team, $offset, $sort_by);
end_cache($cache_args);
end_cache(TEAM_PAGE_TTL,$cache_args);
?>

View File

@ -50,6 +50,6 @@
page_tail();
if ($offset < 1000) {
end_cache($cache_args);
end_cache(TOP_PAGES_TTL,$cache_args);
}
?>

View File

@ -55,7 +55,7 @@
page_tail();
if ($offset < 1000) {
end_cache($cache_args);
end_cache(TOP_PAGES_TTL,$cache_args);
}
} ?>

View File

@ -51,6 +51,6 @@
page_tail();
if ($offset < 1000) {
end_cache($cache_args);
end_cache(TOP_PAGES_TTL,$cache_args);
}
} ?>