Joomler!.net - Decided on Joomla!

デル株式会社

Jboard is Multiple Board!

Home » Blog » baseurl
0 votes
Written by:Joomler! 2956 hits Wednesday, 18 March 2009 16:49

テンプレートを作成したり、Javascriptを変更・開発していたりするときブラウザのキャッシュで2度手間になったってことは経験されたことがあると思います。以下のサイトで動的にリンクを出力することでキャッシュさせない(毎回ロードさせる)方法が紹介されていましたのでそれをJoomla!に適用してみます。

http://davidwalsh.name/prevent-cache

http://www.electrictoolbox.com/javascript-css-file-timestamps/

スタイルシートのlinkタグのhref属性部分を例に

簡単に書く
(デバッグ時のみ動的にする。)

<?php echo $this->baseurl;?>/templates/<?php echo $this->template;?>/css/style.css<?php echo JFactory::getConfig()->getValue('debug')? '?'. time(): '';?>

変更のあったときだけ

$filetime = filemtime(JPATH_THEMES. DS. $this->template. DS. 'css'. DS. 'style.css');
<?php echo $this->baseurl;?>/templates/<?php echo $this->template;?>/css/style.css?<?php echo $filetime;?>

何れもcssのリンクは、スタイルシートのhrefの部分です。

こうすることでブラウザのリロードボタンや、CacheをDisableにする手間が少しは軽減できるのでは無いかと思います。開発時は特に持ってこいかもしれません。また、同じファイル名で画像変更したときのブラウザキャッシュ対策にも使えるかもしれません。

お試しあれ

 

JContentPlus for Joomla!1.5 powered by Joomler!.net

joomler.net is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries.
joomler.net is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.