「最速キャッシュハック」を実験版として公開します。
http://www.peak.ne.jp/xoops/md/mydownloads/singlefile.php?lid=67&cid=2
XOOPS初(?)のページキャッシュシステムで、XOOPSの動作原理に基づいたキャッシュ制御にその特徴があります。
もっとも特徴的なのは、redirect_header() をHackすることで、ベストなタイミングでのキャッシュ破棄ができるだろう、というアイデアです。このアイデアによって、投稿したのに、その結果が反映されない、というページキャッシュシステムにありがちな不具合がなくなっています(いるはずです)。
具体的な内容は、ダウンロードページをご覧ください。
Just a case in this site:
Save 30% of CPU
Use another 30~50Mbyte HDD
Summary
This module adds the standard cache policy to Legacy System. The policy orders Legacy System to make cache files for every groups except the webmaster group.
jayjay wrotes:
Will caching fot users be ignored if I set FASTESTCACHE_EXPIRE_USER to 0? Or is this something you wouldn't recommend?
jayjay wrotes:
Didn't work, but maybe coming close?
else if( ! empty( $_POST ) || $xoopsUserIsAdmin == true || @$xoopsOption['pagetype'] == 'user' || preg_match( '?(/system/|/admin/|register\.php)?' , $_SERVER['REQUEST_URI'] ) ) {
define( 'NOCACHE' , 1 ) ;
}
function fastestcache_static_content_header($mod_timestamp, $cache_expire=0, $max_lifetime=86400) {
$mod_timestamp = intval($mod_timestamp);
$cache_expire = intval($cache_expire);
$max_lifetime = intval($max_lifetime);
if (empty($cache_expire)) $cache_expire = $mod_timestamp+$max_lifetime;
$etag = md5( $_SERVER["REQUEST_URI"] . $mod_timestamp );
header('Pragma:');
header('Etag: "'.$etag.'"' );
header('Cache-Control: max-age='.$max_lifetime);
header('Expires:'.gmdate('D, d M Y H:i:s',$cache_expire).' GMT');
if(!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$modified_since = preg_replace( '/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
if ( strpos( $modified_since, ',' ) === false ) $modified_since .= ' GMT';
if (($mod_timestamp==strtotime( $modified_since ))||
(!empty($_SERVER['HTTP_IF_NONE_MATCH'])&&($etag==$_SERVER['HTTP_IF_NONE_MATCH']))){
header('HTTP/1.1 304 Not Modified');
exit();
}
}
header('Last-Modified: '.gmdate('D, d M Y H:i:s',$mod_timestamp).' GMT');
}
$mod_timestamp = @filemtime( $fastestcache_path );
fastestcache_static_content_header($mod_timestamp, $mod_timestamp+$fastestcache_expire,$fastestcache_expire);
// header( 'Expires: Mon, 27 Jul 1997 05:00:00 GMT' ) ;
// header( 'Cache-Control: private, no-store' ) ;
// header( 'Pragma: no-cache' ) ;
残念ながら拙作WordPressモジュールは、更新時にredirect_header() を使用せずにheader()を直接使用しているため、キャッシュクリアがうまくいきませんでした。
header( ... ) ;
exit ;