PEAK XOOPS - 最速キャッシュハックの実験版放流 in englishin japanese

Archive | RSS |
XOOPS
XOOPS : 最速キャッシュハックの実験版放流
Poster : GIJOE on 2005-12-29 18:36:25 (10175 reads)

in englishin japanese
「最速キャッシュハック」を実験版として公開します。
http://www.peak.ne.jp/xoops/md/mydownloads/singlefile.php?lid=67&cid=2

XOOPS初(?)のページキャッシュシステムで、XOOPSの動作原理に基づいたキャッシュ制御にその特徴があります。

もっとも特徴的なのは、redirect_header() をHackすることで、ベストなタイミングでのキャッシュ破棄ができるだろう、というアイデアです。このアイデアによって、投稿したのに、その結果が反映されない、というページキャッシュシステムにありがちな不具合がなくなっています(いるはずです)。

具体的な内容は、ダウンロードページをご覧ください。

Printer friendly page Send this story to a friend

Comments list

marco  Posted on 2007/9/7 15:54
well, i've noticed that,but my question was on the "fastest" concept.

Quote:
Just a case in this site:

Save 30% of CPU
Use another 30~50Mbyte HDD
have some work around been made on XC/XCL to speed up things upon 2.0x?
gigamaster  Posted on 2007/9/7 7:01 | Last modified
Hi,

Every Legacy module comes with "help" files.
Did you check "help" from Cache module?


Quote:
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.

Salutations,

marco  Posted on 2007/9/7 4:34
how about this feature in XC/XCL? what has been improved in XC/XCL to improve page speed display and scalability?
thx
marco
GIJOE  Posted on 2007/5/13 4:24
Quote:

jayjay wrotes:
Will caching fot users be ignored if I set FASTESTCACHE_EXPIRE_USER to 0? Or is this something you wouldn't recommend?

Perhaps, it is good idea for a site has small user's accesses and large guest's accesses.
jayjay  Posted on 2007/5/12 23:14
Hi GIJOE!

Thanks for the very clear answer

I thought there might have been a possibility because fastest cache makes a difference between guests and users.

Will caching fot users be ignored if I set FASTESTCACHE_EXPIRE_USER to 0? Or is this something you wouldn't recommend?
GIJOE  Posted on 2007/5/11 17:49
Quote:

jayjay wrotes:
Didn't work, but maybe coming close?
No

FCH cannot judge between admin/user/guest because it returns the result without MySQL connection.

Thus, this hack is named "fastest".
jayjay  Posted on 2007/5/9 21:19 | Last modified
Hi Gijoe!

I've implemented your Fastest Cache Hack and it works perfectly! Very satisfied with your work

I'm wondering if one could exclude certain user groups from caching. Let's say the webmaster logs in and he belongs to "'XOOPS_GROUP_ADMIN', '1'". He would like to see the website without caching, so that he can quickly check his changes and correct them if he made a mistake.

The other users will still see the standard "'FASTESTCACHE_EXPIRE_USER' , 300" and guests will still see the "'FASTESTCACHE_EXPIRE_GUEST' , 3600" cache.

Is that possible? How would I go about implementing this?

Edit:
Tried adding this on line 45:
else if( ! empty( $_POST ) || $xoopsUserIsAdmin == true || @$xoopsOption['pagetype'] == 'user' || preg_match( '?(/system/|/admin/|register\.php)?' , $_SERVER['REQUEST_URI'] ) ) {
	define( 'NOCACHE' , 1 ) ;
}

Didn't work, but maybe coming close?
GIJOE  Posted on 2006/1/19 6:50
のぶのぶさん、ありがとうございます。
実は同じ事考えてました

キャッシュ内容を出力する分には、サーバ負荷もほぼ0ですし、HTML本体の帯域負荷も知れてるな、と思ったので手抜きしちゃったのですが、ここまでやった方がベターなのは言うまでもないですよね。

次回、とりこませていただきます。
nobunobu  Posted on 2006/1/14 14:15
実験のついでに、ブラウザキャッシュも有効活用するようにして、サーバの負荷をへらすことを考えてみました。
実は、WordPressの新しい0.6.0 AlphaではRSSなどで同様のことをしているのですが、

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');
}
等という関数を用意して、
fastestcache.php内の、header出力部分を、
    $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' ) ;
等としています。
こうすれば、ブラウザキャッシュが有効になって、サーバのリクエスト回数の減少と
トラフィックの軽減に繋がると思います。
GIJOE  Posted on 2006/1/4 6:51
のぶのぶさん、あけましておめでとうございます。

Quote:
残念ながら拙作WordPressモジュールは、更新時にredirect_header() を使用せずにheader()を直接使用しているため、キャッシュクリアがうまくいきませんでした。
実は、piCalもそうです

header() でも手はあるんですよね。
	header( ... ) ;
	exit ;
こういうリダイレクトでも、出力フィルターは通ってくれるので、関数内の処理で、$_POSTが空、かつ、出力文字列が空なら、header() である可能性が大としてキャッシュクリア、なんて手はあります。

理想は、headers_list() を利用して、どのヘッダが出力されたかを判断する方法ですが、PHP5以降のimplementationなので利用不可能です。

とりあえず実装してみますかね。


$_POST がemptyじゃない時点で、そのユーザのキャッシュをクリア、というのが一番簡単な手ではあるのですが、これをゲストについてもやってしまうと、ヒット率が露骨に低下するかなあ、なんて危惧してます。

いずれも、運用テストするのが一番ですね。
Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!