Monday, June 29, 2009

host wildcard % not working for machine names, only IPs

host wildcard % not working for machine names, only IPs
Posted by: Dewey Gaedcke ()
Date: June 21, 2007 02:19PM


Guys,
I know you can create a wildcard "grant" for local subnet IP's by '192.168.%.%' or all IP's by '%', but this syntax is NOT working when the local subnet resolves as the individual machine name that's trying to connect.
Example: hostname='myPCname' so mysql sees the connection coming from:
username@myPCname instead of username@192.168.1.6
even though they are one and the same address on the subnet

How do you create a wildcard grant that works for all the unique developer machine names that need to connect when they are on a local windows network and the IP is not used???

This is frustrating---all advice appreciated!!
Thanks
Dewey
=======================
I don't know how MySQL does the reverse IP lookup. But if it uses the hosts file first, you could try to add a line like
192.168.1.6 192.168.1.6
to /etc/hosts so that the name resolves to the similar IP and vice versa.

Sunday, June 28, 2009

What is the difference between MySQL server replication and SQLyog synchronization

What is the difference between MySQL server replication and SQLyog synchronization?

Technically they are completely different. MySQL server replication basically operates in the way that the server defined as the 'slave' reads the binary log of the 'master' and replicates operations performed by the master. SQLyog/SJA synchronization uses SQL to query the servers, compares the data using advanced checksum algorithms and performs the INSERTS, UPDATES and DELETES needed to bring databases in sync.

Both methods have their advantages and drawbacks. The most important aspect in favour of the method used by SQLyog synchronization is, that it is possible even if one or both of the databases are in a "shared environment" such as an ISP. You don't need any special privileges to use SQLyog synchronization - only simple SELECT, INSERT, UPDATE and DELETE privileges. And you won't need your own dedicated hardware.

When the SQLyog Job Agent (SJA) connects to the databases that should be synchronized, it does so as any client does. There is no downtime for other users/connections and all data are available for other users while the sync process is running. In that respect SQL server replication and SQLyog synchronization are similar. And as far as the end result goes: having identical databases (if that was what you specified) at both servers they are identical.

What are the differences between Database synchronization and replication

What are the differences between Database synchronization and replication?
Posted by: Pervasync Software ()
Date: January 02, 2009 04:14PM

Database synchronization is closely related to database replication. In fact, sometimes people use the terms interchangeably. However, there are big differences, understanding which will help us understand the different approaches used for solving replication and synchronization problems.

Replication is mostly used in situations where identical replicas of the complete data set are maintained on two or more database instances for high availability and performance reasons. Database instances can often work independently as backups for each other. The relationships between the instances are equal, symmetric. Normally the number of DB instances is small.

On the other hand, in a database synchronization system, typically you have a big central database on the server side and a large number of small databases each residing on a device. The central database contains data for all the devices while each device’s local database only contains the device’s private data and some shared data.

In the non-database world, Synchronization is also often used to describe the data exchange between a more temporal sub-set of data and a more persistent full-set of data. For instance, parts of a file could be buffered in-memory by an operating system and are “synchronized” with the file on hard disk. Another example is the synchronization of the data in a CPU cache memory with the data in the main memory.

Pervasync Software
mailto:info@pervasync.com
http://www.pervasync.com

Replication and synchronization

Replication and synchronization happen to be something about which I
know a teensy weensy little bit. :-) So I'll toss in my 2 cents'
worth.

The easiest thing to implement is the current proposal: one writable
master, and many read-only slaves. Anything that allows writes at
multiple locations is fraught with difficulty. There are a number of
well-known solutions, but all of them have drawbacks, and most require
some complexity.

Multiple-write replication schemes fall into two broad categories:
conservative and optimistic. Briefly, conservative approaches seek to
ensure that there will never be "conflicting" writes (what Nicolas
Fischer called "collisions"). The master/slave method mentioned above
falls into the conservative category. Another popular and relatively
simple conservative approach is the "voting" scheme. Before writing
any record, the writer first contacts a majority of other replicas,
and sets locks on the record. Then it does the write and releases the
locks, propagating the new record as part of the lock-release
message. Clearly, only one writer can lock any record at any time.
Furthermore, if a writer has an out-of-date copy of the record, he can
find out as part of setting the lock.

The disadvantage of this and most other conservative approaches is
that they require a majority of the replicas to be online at any given
time. The voting scheme can be modified slightly by assigning weights
to replicas; a more reliable replica will get a heavier weight, and to
lock you only need to get a majority of the weights.

The one-writable-master scheme can also be modified so that instead of
doing writes directly at the master, a slave first locks the record at
the master, then updates it locally and sends the updated version to
the master. If it chooses, the master can then notify all other
slaves of the new value. This approach is handy if it's important
that all slaves be kept up to date. Many multiprocessor computers use
a form of this approach to keep their caches consistent between
processors.

There are also overhead issues with locking schemes. The number of
messages exchanged can be excessive in some circumstances.

In optimistic approaches, by contrast, every replica accepts writes
without considering the possibility of conflicts. At some later date,
replicas "gossip" with each other to tell each other about updates.
As long as there's no conflict, everything is fine. Otherwise, some
sort of conflict-resolution scheme must be invoked. An early paper
on the idea was titled "Apologizing vs. Asking Permission", which is a
nice summary of the difference between the two methods.

Optimistic approaches can work very well when conflicts are rare. I
suspect that they would be rare in MusicBrainz once it was past the
initial stage of populating the database. However, implementing an
optimistic approach is probably more difficult than doing a
pessimistic one, especially when you consider the work of resolving
conflicts.

I've only touched the surface of a complex subject here, but I hope my
comments will help to serve as a starting point for further
discussion.
--
Geoff Kuenning geoff at cs.hmc.edu http://www.cs.hmc.edu/~geoff/

Software, like bridges, should be elegant and visually pleasing as
well as functional. Ugly constructs, designs, and languages should be
avoided like the plague.

Synchronization Replication Mirroring

Synchronization (PeerSync’s default mode) - files added or updated on the source PC are copied to the target PC or storage device.

Replication - same as "Standard synchronization" (files added or updated on the source PC are copied to the target PC or storage device) and any files on target that do not have a matching source file are deleted (if you delete a file on the source, it will be deleted on the target).

Mirroring – A term often used synonymously with Synchronization.

Error Code: 2006 - MySQL server has gone away

"Error Code: 2006 - MySQL server has gone away"

I think the most likely reason is that the (server) max_allowed_packet setting is too low compared to the size of BULK inserts in the file.

Old server versions dispaly only that in this situation. 5.0.41 say "got a package too big" or something like that!


Thanks that was exactly the problem. Followed the instructions below

http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html

In Linux:

Copy the my-xxx.cnf file from /usr/share/mysql to /etc as my.cnf

xxx can be small, medium, large, huge ... depending on the requirement.

$ cp /usr/share/mysql/my-xxx.cnf /etc/my.cnf

In the my.cnf file, change the default
max_allowed_packet = 1M
to
max_allowed_packet = 16M

Save the file and restart MySQL server.

In Windows:

In the MySQL server installation directory,
in my.ini file, add the following line under [mysqld] in SERVER SECTION.

max_allowed_packet = 16M

Save the file and restart MySQL server.

絕心忘情,登峰造極

月神好美又好帥,揚弓的神態更是英勇柔美。

新人小美和我說了月神的故事。
這是霹靂布袋戲的開疆記中的一段愛情故事。

江湖壞人當道,尤其惡人之守六禍蒼龍,唯有月神以混沌之弓練成獨龍之箭,才能制伏。
但混沌之弓之使用需全心全意,六根清淨,斷絕七情六慾,絕心忘情,才能發揮功效。

月神放棄混沌之弓,只為與心愛的三口劍廝守。
將這保護江湖的重責大任交給姊姊風飛沙,無奈姊姊的精準度卻非如月神這般神準。

三口劍為了江湖,決定放下兒女私情自殺,讓月神能全心全意忘情射箭、殲滅異族,拯救江湖。

看著三口劍在月神面前自殺那幕戲,感人無私的對白。真令人動容>”<

三口劍 : 我在想當初創作混沌之弓的深意究竟是什麼
月神 : 不就是絕心忘情,登峰造極,這是代代月神的悲傷宿命,幸好,我已經擺脫了
三口劍 : 我想不是,為混沌之弓,甘願赴死的那群前輩,他們投身那火爐的那一刻絕不是抱著怨恨的心情,他們的犧牲絕不是為了讓代代月神繼續承受悲傷的宿命
月神 : 那是為什麼
三口劍 : 混沌之弓的真意就是成全
月神 : 成全,那是什麼意思,師父不是這樣教我的
三口劍 : 妳的師父教錯了,混沌之弓的真意是為了停止悲傷,為了讓別人永不再悲傷,犧牲自己的幸福,讓他人幸福,這就是成全
月神 : 為什麼要這麼做,人不是自私的動物嗎,為什麼要別人犧牲自己
三口劍 : 妳也感覺我自私嗎
月神 : 你與他們不同
三口劍 : 這個世界上有很多願意為別人犧牲自己的人
月神 : 我不懂,我也不想懂:這太複雜了.......

結局,月神忍著失去三口劍的痛,重新接下混沌之弓,也殲滅了壞人。
完成使命後,也隨著三口劍走了。

片尾曲雙月影,唱出月神的心痛。
混沌之弓的真意是為了停止悲傷,
為了讓別人永不再悲傷,犧牲自己的幸福,讓他人幸福,這就是成全

真正的高手,內心都有自吾修練的 定 (沉穩 內歛)

真正的高手,內心都有自吾修練的 定 (沉穩 內歛)

Saturday, June 27, 2009

無償的獲得,不會去珍惜。

無償的獲得,不會去珍惜。

團長很喜歡看電影,於是今天又去參加了一部電影的首映會

鏘鏘,就是以下這部




她性感誘人,她溫柔甜美,在兩個完美情人間,你會選擇…


看完影片的時候,我心裡突然浮現了五個字----「無魚蝦也好」

這部影片是可以從很多層次來分析的,如果有人去看了,再來看看我這心裡浮現的
五個字,應該會莞爾一笑。

不過除了這個笑點以外,整體而言,這部影片的後座力還蠻強的,有一種不知名的
感覺會在看完電影的三十分鍾後才會浮現出來,跟看完斷背山的感覺很像。

話說我在看到一半的時候頻頻拭淚,因為我今天載的隱形眼鏡讓我覺得很不舒服,
一直在喬,我想,如果有美眉在看我的話,一定覺得我被感動了,真是性情中人。

這部電影在美國的影評是這樣的…

全美影評與觀眾口碑佳評如潮,今年最動人的浪漫電影首選!

坎城影展正式入選競賽片

全球最大影迷網站IMDb.com給予7.8分超高評價


我覺得看電影前要不要看影評也是值得省思的一件事,因為影評如果寫太好,

去看的時候就會抱著一種預期心理,反而就不好看了,而如果影評寫得不好

,人們就會輕易被這種別人的「口碑」所影響,把一部本來還不錯的影片看到

low掉。


最近看電影,我愈來愈覺得現在的電影工業真的是不好經營,怎麼說呢?由於Youtube等

線上視訊與下載管道的發達,已然改變了許多人看影視的習慣,大家都己經習慣到

網路上抓最新的影片來看,而且還呷好倒燒報,到處分享,這種效應不斷擴散的結果

,已然使得許多人不再上電影院看電影了。


有些人覺得,現在的經濟不景氣,錢能省即省,除非是很好看的影片才會想到電影院看,

不然花了幾百塊卻看到爛片,會感覺很受傷。


有些人則覺得,羊毛出在羊身上,如果現在自己不支持一下電影、棒球、戲劇這種夢想工業

,以後自己想要逐夢時,別人也不會呼應共鳴,大家會一起陷入惡性循環的死亡螺旋,一起

走向無望蕭條的深淵。


有人從經濟學的角度來分析,市場上有一隻看不見的手,會自動調節供需機制,使一切達

到平衡,因此就讓盜版順其自然,反正只要東西做的好就不怕寂寞,生意會自動上門。

話當然可以說得很漂亮,不過資本主義的自由市場機制走到現在的金融風暴,很多專家開

始覺得,這隻市場看不見的手還真的是愈來愈看不見了(我覺得這句話還蠻好笑的)。


現在任何的產品就算做得比以前好十倍,恐怕也是乏人問津,大者恆大,市佔率第一的公司會

吃下將近五十%的市場,二級廠就算再怎麼努力作好,其實也很難撼動領先群的地位,有時看

到一些報章雜誌一直報導創意的重要,我就覺得這可能會造成一種錯誤的認知,既然科技始終

來自於人性,創意也一樣是有周期的,創意如果沒有背後龐大的資源與實力當基礎,會紅也只

是曇花一現。



前陣子假日我去西門町擺攤賣東西,目的是為了感受一下當攤販的滋味,結果我發現,看東

西的人真的超多,一旦拿東西出來要賣時,就全部都不見了,現在消費與供應者的極度不平衡

,讓我覺得實在可悲,我還只是插花的,那些真正靠擺攤維生的社會中下階層,將會是多辛苦呢?


現在的人太聰明了,透過資訊不對稱賺取價差的機會愈來愈難,這樣對大家到底是好還是壞呢?



其實現在不只電影工業是如此,唱片業、出版業也非常蕭條,每個人在網路上都可以看到

免費的新聞,許多有實力的網路寫手寫出的文章也較之作家毫不遜色,就這樣,許多人就再

也不買報紙、買書、看電影、買唱片了。


於是乎,從唱片、底片、電影、音樂到出版、新聞、媒體業,都被網路文化所帶動的宅工業瞬間

秒殺,工業大量生產之後理論上要靠服務業來撐起一片天,不過現在可以看到的是,幾乎所有的服務業

都被網路所取代與侵蝕,如此一來,世界的經濟會變好才有鬼。


我自己是認為,一切有因就有果,洗洗皆可吃,呃,不,是我們怎麼對應外界,外界就怎麼會

回應我們,當我們開始覺得取得的一些知識與訊息是無償廉價的,是垂手可得的,是可以不勞

而獲的,我們對知識的敬重就會慢慢流失,於是我們也就留不住這些知識了。


我幾乎每天都會到圖書館借至少三本書回家看,我本來以為只要一直看書,自然知識的深度與廣

度就無限上升,但我後來發現,看完一本書如果馬上看第二本書,第一本書的記憶馬上就被沖淡

了,原來閱讀後還必需留給腦袋一段沉積的時間,讓知識自己慢慢醱酵才行。


這正如同欣賞完音樂是不能馬上鼓掌的,因為音樂剛剛結束之後的靜默,也屬於音樂的一部份

,是包含在音樂裡面的,唯有連結束時的無寂之聲也一起聽完,才算是真正欣賞了整個音樂。


我也常常去書店翻書,由於大量閱讀的緣故,大概一個小時就可以把五本書的精華吸收完畢,但老
實說這種舉動其實就等於是佔了書店的便宜,我覺得這樣對書店有點過意不去,便至少會買一本
書作為對書店的補償。


拉拉雜雜講了一堆,我要說的是,在無償接收了許多免費的資源後,偶而還是要讓人家賺一下,
並注意消費的平衡性與非集中性,這樣比較能營造互利共生的經濟環境,大家各供所得,也各取所需

會改變的心,不可能滿足於不變的成就

會改變的心,不可能滿足於不變的成就


通常研究所口試通過後畢業的學長姐,對於學弟妹在準備論文期間提出的疑惑與困頓,都會給出一種
反正船到橋頭自然直,時間到了自然就解決的建議,是一種雲淡風輕、談笑用兵的感覺,他們很少會
真的為了學弟妹們而特別呼喚起以往那段深刻鮮明的記憶,畢竟,對於已經畢業的學長姐,該關心的
事情已經不一樣了…

他們從畢業後的時間點向前詮釋到還未畢業時的立場,其實已經跟學弟妹們很不一樣了。

曾經聽過一位己經當爸爸的朋友如是說

「當你結婚,成為一個爸爸後,就開始會覺得,其實結婚的對像是誰都沒關係了」

為什麼呢?

因為己經是一個不同身份與立場的存在了,不論當初感情談的是轟轟烈烈還是雲淡風輕
,都變得沒有差別。

人生某個角度來說是一個無法回頭的單行道, 一旦走到下一個階段,就不在會對前一階
段的 事情太過關心,也不太有興趣談論。

對於後輩而言,這是很可惜的,因為前輩的心得其實都沒有好好的傳授下來。

前輩也可能會想,反正我講了他們也聽不懂,讓他們自己體驗過一次,也就自然知道了。

我們現在非常關心的議題,通常到了人生的另一個階段,意義會完全改觀。

如果是這樣的話,將身上所有的賭注都壓在人生的其中一個階段,會非常冒險,將來很可能
會非常後悔。

正所謂萬變不離其宗,愈變愈相同

如果我們從小到大,不曾為了得到某個東西而開心超過一個月,我們怎麼可以貿然的對
自己說,我現在努力爭取的東西得到以後,就可以高枕無憂了呢?

我們其實會發現,所謂的「成就」,就只是得到時「那一瞬間」的感動,然後就沒有了,
除非你不斷去回味它。


做一件事成功與不成功,都會向時間的軌道單向前進,有事情忙是鴻福,沒事情忙是清福,
所有的「結果」都有雙向發展的可能性

心識之流不斷由現在流向未來,這顆開始流向未來不同立場的心,是要讓它變還是不讓它變?

如果不讓它變,那可能就是停滯、幼稚,因為如果不是這樣,我們的童年就可以宣告它可以填充
我們的一生,但我們不甘心就這樣對吧。

而如果一直讓它變,我們也很害怕,難道那曾經有過的美好回憶,就勢必會因為後來所發生的事
物堆積掩埋,導致我們遺失我們的初心。

我們一方面希望改變,一方面不希望,而這個不希望改變的想法,卻又是會改變的心促成的

能看透這層關係,再來看現在這個階段特別關心的議題,感覺就會不一樣了哦。

過往小小的事件,悄然之間形塑了日後堅定不移的信念

過往小小的事件,悄然之間形塑了日後堅定不移的信念

昨天瀏覽網友的網誌,發現了一則轉貼的網路笑話,覺得特別有意思:

------------------------------------------

期末考睡過頭這種蠢事怎麼會發生在我身上!!!???

馬的...

我整個學期都沒有翹課...


作業也都準時交...

期中考還考92......

上課也很熱切地加入討論...

為什麼...

為什麼我會在期末考那一天睡過頭!!!!

期末考佔學期成績的百分之六十啊!!!!!

馬的!!!!!

算了~再多恨意也無法改變什麼了....

就在我帶著"再也不要睡過頭"的決心去全國電子救甘興買無敵大鬧鍾時...

接到了教授的電話....

。。。

。。。

。。。

。。。

。。。

。。。

。。。

。。

。。







"KIRAN....對不起....老師把妳的期末考考卷弄不見了....

怎麼找都找不到......


妳期中考考92.....老師直接幫妳算90分會不會太少??"

------------------------------------
為什麼我會覺得這篇文章特別有意思呢

因為我小時候也有同樣的經驗


國中的時候,我也是像現在一樣喜歡亂塗鴨,畫漫畫
有一天心血來潮,在作業本上畫起了漫畫
不知怎麼的,漫畫開始受到了同學的歡迎
還紛紛給了很多的創作題材與建議

所謂社會大眾的新聞口味,應該是從小就養成的
為什麼會這麼說呢?

因為畫一些關於老師的流言誹語,最能引起同學們的興趣

後來我畫了一系列的老師異想醜聞漫畫

這部作品不知怎麼的,洛陽紙貴,還傳到別班去,成為了大家
爭相推薦的熱門刊物

每個星期,都會有別班同學來問,這一期出刊了沒,跟當年的少年快報
一樣。

其實另一班也有一個跟我一樣畫漫畫的同好

他畫漫畫超快的,一天可以畫一本,不過,他的漫畫比較沒有人看

因為,他畫的太快了,快的像是鬼畫符--

「請問主角在哪裡」我一邊看著他的漫畫,一邊問

「這裡,這個是孫悟空」他指著一團爛泥對著我說

「那這個又是誰? 」我指著另一團他漫畫中比較小的爛泥說

「這個是蹲下來的孫悟空」


我的漫畫就這樣成為漫畫同人誌排行榜冠軍
因為沒有人看得懂另一位在畫什麼
(參賽者總共也只有二位)

有一天,東窗事發了


原來是我們老師去別班上課的時候,發現別班同學上課居然在偷看漫畫

沒有錯

偷看的就是我畫的漫畫

而且畫的內容

就是編造的這位老師的醜聞

據說老師相當的生氣,我們導師是女老師哪


---------------------------------------
第二天老師回到了班上

「昨天,我在別班同學的身上,發現了這本漫畫」

啊,好熟悉的封面,那不是我的名著嗎?

「誰畫的,老實承認」

由於班上最會畫畫的不作第二人想也屈指可數,我只好怯生生的舉手

此時老師看著我,露出了有點驚訝的表情。

老師若有所思了一下

「我相信這是他畫的沒有錯,但我不相信這劇情是他編的,是誰把這漫畫的情節編出來要求他
畫的,快點承認哦!!」

我那時還真不懂老師為何要如此問,這漫畫明明是我編的也是我畫的啊?老師何必又要多問
這個問題呢?

正當我要再度舉手承認時

「老師,劇情是我編的,是我叫他畫的」一位素來以在班上惡作劇為名的同學居然站起來承認

我當時還蠻震驚的,因為這根本與他沒有關係,而也由於震驚過度,我連想要說出真相

的行動也頓時癱瘓。


「我就知道,果然這種不尊師重道的情節是你編的,出來!!」老師很生氣的叫他出來

結果他被重重的修理了一頓,還要求他罰寫一千遍


而漫畫的始作俑者,我呢?


居然完全沒有受到任何懲罰…

這樣未免偏心的也太明顯了吧?

奇怪的是,下課的時候居然也沒有同學發出抗議之聲,或是理論上該有的疑惑耳語

我知道老師對我的印象一直很好

還曾經在課堂上公開的稱讚過我

不過,我的人緣有好到這種程度嗎?

而這位同學的人緣又有差到這種程度嗎?


我覺得對這位同學有點過意不去,便要求與他一起分擔一半的罰寫量

(其實我跟他很好,平常都一起上下學)
----------------------------------------

這件事雖然只是小事
卻讓我見識到所謂「印象」的威力

在後來人生的長河中
面對挫折與挑戰的時候
我總會有一種反正到後來一定會沒事的直覺反應
一種相信自己就是運氣好的自覺


可能是這個事件

讓我察覺到自己身上似乎有某種特質
可以享有吉人天相、免死鐵券的待遇

而我那位挺身而出的同學

他所得到的禮物,就是反正被誤會也沒差這一次的膽識,讓他某個程度上

無所畏懼的邁向他未來的人生長河

是福是禍,總還是看個人的認知來裁奪的


說起來這種以為自已是天之驕子的感覺
可能只是一種錯覺


但這個從小時候給我的這種錯覺
無形中給我勇氣
讓我有得以面對艱險世界的信心
像是感受到自己是被天神與眾人眷顧的存在


很多小時候埋藏在內心的東西
就這樣無形的構成了我們人格的基礎
這是我的得天獨厚嗎?


事到如今

我知道這麼想是不對的
但我倒是很樂意這麼想的


從這個角度觀來

別人對我們的第一印象或刻版印象

會在某種程度上決定了我們對自己的看法

有很多人是一出生或許因為長的可愛、表現乖巧而被期待盼望、差別對待

有的人則是一出生後父不庝、母不愛,久而久之發展出扭曲的人格



這種久而久之、我們早以忘記,而不在意識層面下可以覺察到的差別

或許正是所謂命運的差別。

敗軍之將不可言勇

敗軍之將不可言勇

這就是態度!

這就是態度!

既然上了賊船,就要做最出色的海盜

既然上了賊船,就要做最出色的海盜

php utf-8

<?php
//mb_internal_encoding("UTF-8");


$conn = mssql_connect( "MyServer2k", "user", "password" );
mssql_select_db('testing', $conn);



$query = "select top 10 * from member2";
$result = mssql_query( $query );

while( $row = mssql_fetch_array( $result ) ) {
//echo strtoupper(ucs2toutf8($row['title']))."<br>";
//echo iconv('UCS-2LE', 'UTF-8', $row['title'])."<br>";
$title = $row['note2'];
//$whichcode = mb_detect_encoding( $row['title'], "auto" );
//$whichcode = is_utf8( $row['title'] );

//$title = mb_convert_encoding( $row['title'], "UTF-8", "UCS-2LE" );

//$title = preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$title);

//$title = iconv( "", "UTF-8", $title );

//$title = ucs2html( $title );

echo $title."<br>";
}

echo "code: ".$whichcode;



function is_utf8($string) {

// From http://w3.org/International/questions/qa-forms-utf-8.html
return preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string);

} // function is_utf8

function ucs2toutf8($str)
{
for ($i=0;$i < strlen($str);$i+=4)
{
$substring1 = $str[$i].$str[$i+1];
$substring2 = $str[$i+2].$str[$i+3];

if ($substring1 == "00")
{
$byte1 = "";
$byte2 = $substring2;
}
else
{
$substring = $substring1.$substring2;
$byte1 = dechex(192+(hexdec($substring)/64));
$byte2 = dechex(128+(hexdec($substring)%64));
}
$utf8 .= $byte1.$byte2;
}
return $utf8;
}
function CP1251toUTF8($string){
$out = '';
for ($i = 0; $i < strlen($string); ++$i){
$ch = ord($string{$i});
if ($ch < 0x80) $out .= chr($ch);
else
if ($ch >= 0xC0)
if ($ch < 0xF0)
$out .= "\xD0".chr(0x90 + $ch - 0xC0); // А-Я, а-п (A-YA, a-p)
else $out .= "\xD1".chr(0x80 + $ch - 0xF0); // р-я (r-ya)
else
switch($ch){
case 0xA8: $out .= "\xD0\x81"; break; // YO
case 0xB8: $out .= "\xD1\x91"; break; // yo
// ukrainian
case 0xA1: $out .= "\xD0\x8E"; break; // Ў (U)
case 0xA2: $out .= "\xD1\x9E"; break; // ў (u)
case 0xAA: $out .= "\xD0\x84"; break; // Є (e)
case 0xAF: $out .= "\xD0\x87"; break; // Ї (I..)
case 0xB2: $out .= "\xD0\x86"; break; // I (I)
case 0xB3: $out .= "\xD1\x96"; break; // i (i)
case 0xBA: $out .= "\xD1\x94"; break; // є (e)
case 0xBF: $out .= "\xD1\x97"; break; // ї (i..)
// chuvashian
case 0x8C: $out .= "\xD3\x90"; break; // Ӑ (A)
case 0x8D: $out .= "\xD3\x96"; break; // Ӗ (E)
case 0x8E: $out .= "\xD2\xAA"; break; // Ҫ (SCH)
case 0x8F: $out .= "\xD3\xB2"; break; // Ӳ (U)
case 0x9C: $out .= "\xD3\x91"; break; // ӑ (a)
case 0x9D: $out .= "\xD3\x97"; break; // ӗ (e)
case 0x9E: $out .= "\xD2\xAB"; break; // ҫ (sch)
case 0x9F: $out .= "\xD3\xB3"; break; // ӳ (u)
}
}
return $out;
}

function ucs2html($str) {
$str=trim($str); // if you are reading from file
$len=strlen($str);
$html='';
for($i=0;$i < $len;$i+=2)
$html.='&#'.hexdec(dechex(ord($str[$i+1])).
sprintf("%02s",dechex(ord($str[$i])))).';';
return($html);
}
?>

我認為Dell所想的不只是降低損失

我認為Dell所想的不只是降低損失
畢竟這也是一個機會
ex:
Dell可以提供特惠價 + coupon
999元的LCD,原本網站賣5800,市價5300
變成 3999 但送 1000元*3 coupon (三個月期,下次購物才能使用,買萬抵千)
一定程度避免掉有人大量買入再賣出的情形
又可提早吃掉一部分暑假後開學潮的市場
而原本的訂購的人,會想那三千coupon送禮、自用、賣人都可
3999也夠便宜了

除了19" 20" LCD外,那天訂22"、23"、 筆電、桌電的人應該也不少
這些東西因為本身單價較高,所以原本的給的折扣也較多
即使折7000賣,和原本的售價可能就只差個幾百元~1000元
但這部份的售出不需要給零售商和sales獎金的,公司實際所得是一樣的
也可以藉此將產品賣給他們
而不會被訂19" 20" LCD的人批評說差別待遇

我不是dell的人,只覺得既然損失是一定會有
想辦法將這些損失變成一種未來獲利的基礎
這比較符合大公司應該思考的方向

+1

這才是聰明人的做法. 這樣事情處理掉了, 還變向廣告搶同行生意...

Friday, June 26, 2009

如何一年讀一千本書,超效率讀書法

如何一年讀一千本書,超效率讀書法
0
推薦
如何一年讀一千本書,超效率讀書法

文/zen

昨天看完石田衣良的《池袋西口公園》,書中提到石田每年讀一千本書。有些人覺得不可思議,平均一天讀2.7本書。但是我回頭想想,這幾年出社會工作之後,我一年平均也大概讀了五六百本書(全部從頭到尾看完的),若加上略讀書籍內容而看的,大約有一千本。若只是翻讀了解書籍出版狀況分類的,約兩三千本。漫畫雜誌的話每年也讀掉一兩千本有。

本文都將介紹這麼大量的圖書資訊,是如何閱讀並且消化吸收的。但是我想說的前提是,每個人都作得到。只是有沒有運用一些方法,還有一些動力而已。

基本上,在文字書閱讀上,我保持著一天至少讀完一本書,最多一天可以讀四本書的閱讀速度。

如何能夠讀這麼多書?是不是一天到晚都在讀書?其實並不是!每天我還做很多事情。上班、寫稿、煮飯、發呆、看電視、賴床,還有社交生活。那麼是如何能夠讀這麼多書?其實是有方法。

在談方法之前,先說一說我後來歸結出來的屬於我自己的事先基礎。上大學時,因為迎新宿營玩過頭,不小心腳受傷,調養了好一陣子。因為哪裡都不能去,遂養成逛圖書館的習慣。我開始辨認圖書館中每一個類別分類,看到有趣的書就拿出來翻一翻,看看目錄、看看出版社、書系、作者,久了,在自己的腦袋裡形成一份屬於自己的圖書分類地圖。

大學四年我幾乎天天到圖書館報到。輔大有三個圖書館,分別是社會科學圖書館、理工學院圖書館和文學院圖書館,總共的中文藏書約莫六十萬冊。我和其他同學不同,我從不使用電腦查書。每天我就是圖書館書架看有沒有想要看的書,若是有就借回去(因為書其實並不多,用電腦查還不如直接逛一次圖書館看有沒有自己要的書快)。因為不能借很多書。因此,每天耗在圖書館翻看那些不能借走(或不值得借走的書)。久而久之,三家圖書館的每個藏書架上有哪些書,慢慢摸熟了。我的腦袋裡也慢慢形成了自己的圖書分類地圖。

由於大學時代的我想要念博士,進學校當老師。因此對於知識的學習閱讀非常的熱衷。大二之後,每天借回宿舍的書,除了讀、我還會寫筆記,然後把筆記分門別類。後來大學畢業雖然不再寫筆記,但那幾年寫下的筆記,也有滿滿一個行李箱(最近這次搬家後就鎖在一個大行李箱中)。寫筆記雖降低閱讀速度,重複閱讀一些重要的文字段落,讓自己習慣各種領域學科的文字使用方式、概念鋪陳模式與思維邏輯,更讓自己對於學科領域的劃分有了更精準的了解。而我也針對自己有興趣的閱讀門類,設計檔案夾,整理筆記。

大學時代算是尚未熟手,因此大四畢業時我去三個圖書館看了我的借閱紀錄,加起來大概一千本左右。若加上我在校外圖書館借的自己買的,和朋友借的林林總總加起來,每年應該也讀了不少書。

除了逛圖書館所練出來的圖書分類架構,閱讀寫筆記去實際了解各個學科文字概念的使用思考邏輯學術術語外,我幾乎每個學科領域的教科書或者有類似思想史的書,都會借回來讀。思想史或者入門教科書的好處是,快速而全盤且系統的掌握該學科的範疇重要研究領域概念與,思維特點,設法進入那套語言遊戲規則中,了解過去有哪些重要的研究成果(特別是思想史的書)。未來再遇到同樣性質的書籍時,將不會覺得閱讀上的進入障礙太大(畢竟先打過照面拜過碼頭了)。

很多人無法讀書快速或者覺得書中內容很難以理解掌握,其實最根本的原因在於對於該學科所使用的語言和概念了解太少,或者太求甚解的關係。

我讀書一向抱著不求甚解的態度。畢竟我只是因為好玩、覺得有趣、想要知道書裡面寫什麼才去讀。因此讀不懂並不會有什麼損失。而很多書也是在我這樣的魯莽之下硬讀死讀而慢慢讀完的。就像中國人古時候私塾教育先不解釋四書五經,就是要求你不斷的背,背久了自然就能夠心領神會。這套方法真的很神奇,讓人對於文字密度過濃或者學術概念過多的學術書,都能夠輕易的克服。

而我會採取這種讀書方法,是因為我是一個從小就很難專心,而且很難乖乖待在書桌前讀書的人。所以國高中的時候,必須背很多無聊東西的我,為了怕無聊,只好買盡坊間的參考書。因為我讀完一本之後,很少願意會在重頭看同一本。我寧願多看幾遍不同的書,也不願意停下來一直死背。這也是我學業成績一直普普通通的原因。因為我無法忍受自己為了那百分之十的分數,而浪費百分之百的時間(少了看電視看漫畫和玩樂時間是很痛苦的)。學習的精通,不是只有靠把小地方背的熟悉而已,還可以藉由廣博的閱讀,累積通盤的思考架構和視野來完成。而這也成為我往後的閱讀和學習基調。

大學畢業後,進入研究所。由於離公館近,再加上當時已經染上買書的壞習慣,又開始在書店打工(我在簡體字書店、人文書店打過工),因此逛書店幾乎成為我每天例行的工作。而台大總圖和法學院圖書館,也是我繼續累積閱讀地圖的地方。畢竟輔大的外文書不多。進入台大以後,台大的中文書可以用殘破不全來形容,幾乎都被借出去了。因此我轉攻累積英文書目。每天去逛圖書館,就是借一大堆自己有興趣的作者或領域的書回家,然後般去影印店印(想說學費那麼貴撈一點回來,一學期印個二十本我就划算了),還呼朋引伴的找學長同學一起印。那時候買書印書花錢花的很兇,也因此打工也打的很兇,但是書還是每天借每天印每天買每天讀。

念研究所,許多人都覺得光是上課指定教材都讀不完了,哪有空在看其他書。可是我除了開學科的指定教材外,還會去找老師指定教材外的所有課外參考書目。如果圖書館有,那一定印,而且不只如此,我還去蒐集沒有要修的課的教材和指定教材參考教材。甚至到最後,只要是該領域的相關圖書,無論中英文,有的就印就買。有空就拿出來翻讀。那段歲月,甚是瘋狂。甚至迷上某些英文出版社的書系,瘋狂的收集購買,像是sage的tcs系列就是我的心頭好。Routliedge 的書我也很愛,polity也是一寶。

除了上述所說,念研究所之後,我還開始接觸出版業,接一些校稿工作之外,印書買書逛書店,也繼續進行著。而且我還進入書店打工。在書店看店時,又繼續我逛書店、逛書架、背書架、認出版社、認書系的工作。久而久之,我開始了解哪些出版社出哪些領域的書,哪些出版社有哪些重要書系,書系裡面有哪些重要作品,市場上最近的出版趨勢和方向。重點書在書店怎麼擺、怎麼行銷等等。還有版權頁裡面的許多奧秘。

在明日工作室打工的七個月間,我有幸一邊賺錢一邊把我過去比較薄弱的文學領域補齊。那時候就是每天穿梭在文人和他們作品的電子化的工作,再加上同事都是文人背景,每天接觸之下,不久之後也大概搞熟了台灣文壇的來龍去脈。那陣子也讀了一兩百部的中文創作,像是蘇偉貞(附帶說一句,真是個好人)、董橋,都是那陣子讀的,甚至還讀了《寒夜三部曲》。沒辦法,校稿賺錢當然挑厚的書讀。

總之,因緣際會之下我靠自己的胡亂閱讀、摸索找出了一套圖書分類架構,以及辨認圖書內容吸收各領域專業知識的方法。有了一個架構之後,慢慢駕輕就熟。而進入書評這個工作之後,我更是勤於尋找市場新書。因為當時還是超級菜鳥的我,只好努力辨認市場上值得推薦的新書,培養書感,好讓自己能夠有較多機會撰寫書評。

畢業之後,更有幸進入知名大型連鎖書店商品處擔任採購工作,負責新書的進貨下量等工作,更讓我接觸的面向從學術專業轉向更普羅大眾的一般書、立志書等等。還有開始和各類刊物媒體合作書評的工作也緩慢的推進,讓我更勤於收集出版資訊。但是擔任採購期間的學習真的收穫良多。因為整個中文線的同事加起來,就等於是全台灣的出版風貌。不能不說豐富。而每周固定閱讀暢銷書的銷售數字,看系統中過往圖書品項的銷售狀況等等,都有助於書感的建立和對新書出版後的市場判斷。慢慢的,對於各種領域的新書、舊書,我都充滿興趣,在我腦袋裡也慢慢的畫出台灣出版市場一個個的分類架構(當然英文書和簡體字圖書也用同一套方法在其他領域中培養著,但是沒有那麼齊全)。

有了這份漫長的準備工作之後,讀書對我來說變成日常生活裡不可或缺的一件事情。通常我不會一次只讀一本書,除非那本書太吸引人,我才會丟下手邊其他的書專心去看。或者因為要工作的關係,只好趕讀。一般的話,我都同時進行五六本書。廁所裡讀小品文,搭車時讀短篇小說,在家讀稍有點難度的人文社科類圖書,在公司讀不用大腦的生活風格類圖書旅遊書商管書雜誌,到漫畫店當然是看最新漫畫囉!晚上有比較完整的時間,則讀工作要用的書。通常一周可以讀完七到十本書左右的工作用書,再加上自己的私人閱讀累積起來的量,也頗可觀。

至於讀書為什麼這麼快,我只能說是熟能生巧!因為大量閱讀的緣故,因為廣泛閱讀的緣故,已經非常熟悉各類文本的書寫模式和論述手法。因此閱讀障礙相對縮小,除了某些超級經典集的哲學書(例如《存在與虛無》、《存在與時間》、《資本論》,這三本我都讀了一個月,當然中間有讀其他書拉)外,其他的書在閱讀上都速度都是可以調整的。

舉例來說,一本三百頁左右的翻譯小說,可以控制在一個半到三小時讀完。如果想要好好享受,就放慢一點讀;若是還可以,就看快點。當然偶爾也會碰到讀一讀就放棄的。

我是社會科學背景出身的關係,是念理論書出身的,因此讀起充滿概念與論證的書,若是熟悉的領域讀起來,反而比小說更快。好像是今天下午我就讀完了《回歸政治》,加上作筆記寫書摘心得,約兩個小時多一些。而魯一士《痛苦的奧秘》全書一百五十頁左右,由於該書太好讀而且讀起來很舒服,約莫一小時讀完(這本書裡討論很多常在bbs基督教板上被無聊人士挑戰的無聊問題。例如神若是全能為何容許苦難等問題)。

通常讀太多書的問題是讀完後很難回想精確的字眼,但其實這並沒有關係。特別只是讀爽的時候。因為這些書都會擴充腦袋對於文字的認知基模,將來越讀就會越上手。

或許你沒有那麼多時間,也不想讀那麼多書。那麼在自己有興趣的領域裡,持續的閱讀。認清楚台灣大致有哪些出版社、書系、作者或重要著作,架構起一個簡單的地圖。自己讀過多少,安排閱讀進度。另外最重要的是,好好找幾本不錯的入門書打底當基礎(讀辭典我也頗推薦)。最重要的是,把這套世界所使用的文字邏輯和思考結構搞清楚。以後再閱讀上,就不會那麼充滿困惑和痛苦。

通常讀者會對於閱讀感到痛苦,也並非一定是不想讀,而是讀不懂,至於為什麼會讀不懂,很抱歉的說,就是沒程度。沒程度不是批評,而是沒有接觸。沒接觸就是沒程度阿。生疏自然就會緩慢。唯一最好的辦法就是勤加練習。把看新聞八卦和無聊週刊的時間省下一部分,安排自己每天的固定閱讀時間。先架構出自己決定要一直讀下去的文類,一陣子之後,自然就可以駕輕就熟,而最後還能觸類旁通。

現代社會犯的一種毛病就是專業主義,好像某個出身的人才能(會/懂)某各領域的書,其實大部分的專業還不是我們自己從書上學來的。你說上大學一學期一門可不過就教那一本教科書(至於研究所台灣最狠的,我碰過的也就是每周一本英文書【聽說芝加哥社會學博士班一門課一周五本英文指定教材,這已經是世界頂級】不過很難喔像是紀登思的《社會的構成》,盧曼《社會系統》【這本兩周】這種等級的),可是那本教科書我大概花兩三天就可以讀完了,而且大概懂個五六成。若是想要熟一點,就多讀幾本。至於難一點的領域,除了哲學社會科學外,我剛好都沒興趣,所以沒差。但是,如果有興趣的人,我相信除了遇到關鍵的地方需要人提醒和點撥外,大部分時間還是需要自己願意靜下心來,硬著頭皮去讀才能夠突破那個障礙。培養出對某一個學門的思維邏輯的感受力。

以上就是我認為我之所以讀書可以讀的很快的原因,不是因為我學了速讀,也不是因為我做了記憶力練習,而是因為我的大腦裡累積了很大量認識世界的概念的知識庫,有一個清楚全盤而系統的架構,願意持續不斷的閱讀。對世界越不陌生,閱讀自然就越沒有障礙(理解力和觸類旁通能力也會大幅提升喔)。

像最近我迷上蔡瀾,可他是個老前輩阿,出了的書總有七八十本了吧!我先搬了十本回來讀,很有趣阿。有時候不小心就讀掉一本,開心的很。

以前這樣蠻幹的還有讀金庸、柏陽、張愛玲、林文月、董橋等人的作品,或者碰上一個學門有興趣,就會悶頭進去讀。我讀過最痛苦的是胡塞爾的書,那時候讀現象學簡直是要我的命,一個晚上讀不到十頁讀的我,嘔心瀝血、讀完還不知所云。後來總也算讀懂點東西。

程式設計高手的八大奧秘

成為程式設計高手的八大奧秘, 作者:白星海(大陸知名程式設計師)

不知不覺做軟體已經做了十年,有成功的喜悅,也有失敗的痛苦,但總不敢稱自己是高手,因為和我心目中真正的高手們比起來,還差得太遠。世界上並沒有成為高手的捷徑,但一些基本原則是可以遵循的。

1、扎實的基礎

資料結構、離散數學、編譯原理,這些是所有電腦科學的基礎,如果不掌握它們,很難寫出高水準的程式。程式人人都會寫,但當你發現寫到一定程度很難再提高的時候,就應該想想是不是要回過頭來學學這些最基本的理論。不要一開始就去學OOP,即使你再精通OOP,遇到一些基本演算法的時候可能也會束手無策。因此多讀一些電腦基礎理論方面的書籍是非常有必要的。

2、豐富的想像力

不要拘泥于固定的思維方式,遇到問題的時候要多想幾種解決問題的方案,試試別人從沒想過的方法。豐富的想像力是建立在豐富的知識的基礎上,除電腦以外,多涉獵其他的學科,比如天文、物理、數學等等。開闊的思維對程式師來說很重要。

3、最簡單的是最好的

這也許是所有科學都遵循的一條準則,複雜的質能轉換原理在愛因斯坦眼裏不過是一個簡單得不能再簡單的公式:E=mc2。簡單的方法更容易被人理解,更容易實現,也更容易維護。遇到問題時要優先考慮最簡單的方案,只有簡單方案不能滿足要求時再考慮複雜的方案。

4、不鑽牛角尖

當你遇到障礙的時候,不妨暫時遠離電腦,看看窗外的風景,聽聽輕音樂,和朋友聊聊天。當我遇到難題的時候會去玩遊戲,當負責遊戲的那部分大腦細胞極度亢奮的時候,負責編程的那部分大腦細胞就得到了充分的休息。當重新開始工作的時候,我會發現那些難題現在竟然可以迎刃而解。

5、對答案的渴求

人類自然科學的發展史就是一個渴求得到答案的過程,即使只能知道答案的一小部分也值得我們去付出。只要你堅定信念,一定要找到問題的答案,你才會付出精力去探索,即使最後沒有得到答案,在過程中你也會學到很多東西。

6、多與別人交流

三人行必有我師,也許在一次和別人不經意的談話中,就可以迸出靈感的火花。多上上網,看看別人對同一問題的看法,會給你很大的啟發。

7、良好的編程風格

注意養成良好的習慣,代碼的縮進編排,變數的命名規則要始終保持一致。大家都知道如何排除代碼中錯誤,卻往往忽視了對注釋的排錯。注釋是程式的一個重要組成部分,它可以使你的代碼更容易理解,而如果代碼已經清楚地表達了你的思想,就不必再加注釋了,如果注釋和代碼不一致,那就更加糟糕。

8、韌性和毅力

這也許是“高手”和一般程式師最大的區別。高手們並不是天才,他們是在無數個日日夜夜中磨煉出來的。成功能給我們帶來無比的喜悅,但過程卻是無比的枯燥乏味。你不妨做個測試,找個10000以內的素數表,把它們全都抄下來,然後再檢查三遍,如果能夠不間斷地完成這一工作,你就可以滿足這一條。

Wednesday, June 24, 2009

select all table name all field name in one database

select all table name all field name in one database


use your_db_name
go

SELECT
o.name, c.name, t.name
--o.name
FROM sys.objects o
JOIN sys.columns c ON o.object_id = c.object_id
JOIN sys.types t ON c.system_type_id = t.system_type_id
WHERE
t.name not like 'sysname'
and o.name not like 'sys%'
and o.name not like 'queue_messages%'

--group by o.name
ORDER BY o.name
go

Tuesday, June 23, 2009

Windows 管理 (manage) > 服務 裡面的東西,,像是裝 apache, mysql 後會出現在那

Windows 管理 (manage) > 服務 裡面的東西,,像是裝 apache, mysql 後會出現在那
那個叫做 service controller,可以用 start > run > cmd > sc.exe 來呼叫

因為米沙剛裝 MySQL 是用 "解壓縮直接用" 而不是 "安裝版" 的版本

所以在 我的電腦 > 右鍵 > 管理 > 服務 這裡面沒有 "MySQL"

要在這新增的方法是

把 CMD 打開,然後輸入

sc create MySQL555 binPath= "\"D:\uo\MySQL Server 5.0\bin\mysqld-nt\" --defaults-file=\"D:\uo\MySQL Server 5.0\my.ini\"" DisplayName= "MySQL555aaaaa"

我試了好陣子才試出來,注意:

1. 等號 = 後面有空格 ( 但參數後面的 等號 = 不用空格)
2. 路徑要用 \" \" 框起來

sc.exe 還有其它的功能 和 選項 / 參數等,有興趣的自己看看

ps. 以下是別人說得,正港把它貼上
上文有一個錯誤。
and you must NOT specify any other run mode
argument, such as --daemon, --tunnel, --inetd, or any of their short
forms. There is no short form for --service.

因此不能使用 -r 而應該用 --root
===============================================


Running Apache as a Service

Apache can be run as a service on Windows NT. There is some highly experimental support for similar behavior on Windows 9x.

You can install Apache as a service automatically during the installation. If you chose to install for all users, the installation will create an Apache service for you. If you specify to install for yourself only, you can manually register Apache as a service after the installation. You have to be a member of the Administrators group for the service installation to succeed.

Apache comes with a utility called the Apache Service Monitor. With it you can see and manage the state of all installed Apache services on any machine on your network. To be able to manage an Apache service with the monitor, you have to first install the service (either automatically via the installation or manually).

You can install Apache as a Windows NT service as follows from the command prompt at the Apache bin subdirectory:

apache -k install

If you need to specify the name of the service you want to install, use the following command. You have to do this if you have several different service installations of Apache on your computer.

apache -k install -n "MyServiceName"

If you need to have specifically named configuration files for different services, you must use this:

apache -k install -n "MyServiceName" -f "c:\files\my.conf"

If you use the first command without any special parameters except -k install, the service will be called Apache2 and the configuration will be assumed to be conf\httpd.conf.

Removing an Apache service is easy. Just use:

apache -k uninstall

The specific Apache service to be uninstalled can be specified by using:

apache -k uninstall -n "MyServiceName"

Normal starting, restarting and shutting down of an Apache service is usually done via the Apache Service Monitor, by using commands like NET START Apache2 and NET STOP Apache2 or via normal Windows service management. Before starting Apache as a service by any means, you should test the service's configuration file by using:

apache -n "MyServiceName" -t

You can control an Apache service by its command line switches, too. To start an installed Apache service you'll use this:

apache -k start

To stop an Apache service via the command line switches, use this:

apache -k stop

or

apache -k shutdown

You can also restart a running service and force it to reread its configuration file by using:

apache -k restart

By default, all Apache services are registered to run as the system user (the LocalSystem account). The LocalSystem account has no privileges to your network via any Windows-secured mechanism, including the file system, named pipes, DCOM, or secure RPC. It has, however, wide privileges locally.
Never grant any network privileges to the LocalSystem account! If you need Apache to be able to access network resources, create a separate account for Apache as noted below.

Sunday, June 21, 2009

渾身是勁

渾身是勁

Thursday, June 18, 2009

network card extremely slow host-to-guest file transfers in VMWare 2.0 beta 2

network card extremely slow host-to-guest file transfers in VMWare 2.0 beta 2
Published
by
kent
on June 20, 2008
in cyber security
. 2 Comments Tags: CentOS 4.0, CentOS 4.6, extremely slow network, guest, host, Intel 82566mm, large send offload, LSO, RHEL 4.0, RHEL4.6, slow file transfers, T61p, TCP segmentation offload, TSO, virtual machine, VMWare 2.0.

In case anyone else encounters this problem, I am making a quick post on this. I am running Windows Server 2008 Standard on my T61p Thinkpad with WVWare Server 2.0 beta 2 and have a guest OS running CentOS (RHEL) 4.6. NIC on my T61p is an Intel 82566MM GigE. With an SSH file transfer from my Win2k8 host to my CentOS 4 guest, encountered extreme slowness…like 5kb/s. That is like modem speed. I updated the CentOS kernel perhaps thinking that the problem would lie there. No change. A little googling and I found that TSO (tcp segmentation offload) needs to be turned off on the host OS NIC settings. The Windows equivalent of TSO on the Intel Driver is called Large Send Offload, or LSO. So I disabled this on the IPV4 properties and bingo. Now getting 800kb/s.

有些事你現在不必問,有些人你永遠不必等

有些事你現在不必問,有些人你永遠不必等

最近很喜歡唱這兩句,「有些事情你現在不必問,有些人你永遠不必等」

禮拜天我被放鴿子了,在做了那麼多準備,以為可以送個東西讓他開心
順便恭賀考上教師資格+送別的紀念品
花了很多心思,最後是在禮拜天中午傳簡訊告訴我「不好意思,我可能要爽約了」

因為前一天他朋友幫他辦了個離別趴,在禮拜六告訴我這件事情之後,
我就問他,「該不會禮拜天晚上就爽約吧」,
他還認真的跟我約了時間地點,結果還是又當了一次希望之鴿

我相信,在他跟我約的那當時,是真的要跟我約的
只是有好玩的事情發生了,我的重要性就理所當然往後移
突然有種很徹底的體悟,他沒把我當一回事
即使我花了這麼多心思在他身上

所以,這算是癡情還是愚蠢,
同樣的事情在電視裡面發生,那男主角叫做癡情
換在現實生活發生,我一直被叫做笨,一直被問說「值得嗎?」
沒想過值不值得的問題,對他好只是因為想對他好,
因為喜歡所以想讓他開心,想替他做些事情

突然間想起「有些事情你現在不必問,有些人你永遠不必等」
矛盾的是,即使知道這個人就算等了,也不會對我有回應
理智說應該要放棄,另外的情感面卻想著,並沒有打算要求什麼回報
又幹嗎計較這麼多

所以就腦袋轉呀轉的,轉不出去了
誰幫我分別一下癡情跟愚蠢的差別?也許我會想通

RAID

RAID
你如果是有現成的版子,就找 raid 卡來試試.我覺得 LSI 這種大牌子不會有啥問題.話說他把 3Ware 買下來了

SATA - Advanced Host Controller Interface

SATA - Advanced Host Controller Interface

Tuesday, June 16, 2009

PHP file_get_contents function slow

PHP file_get_contents function slow

there are few possible issues:
- fileInfo 不選?
- CGI 不選?
- Socket 選?
- Hardened-PHP Project. Suhosin Protection disabled it?
- IPv6 不選 (FreeBSD, Apache, PHP, 都不要去 support IPv6 的款)

Monday, June 15, 2009

Exclude directory in tar and zip

OK - I figured it out. It turns out the GNU Tar which I have as I use
Ubuntu requires that the path to be tar'd come after the exclude
options. The example listed here had it before.

TAR:

tar -cvf httpdocs_06_20_2006.tar.gz
/home/user/domain.com/site
--exclude "/home/user/domain.com/site/excluded-dir1"
--exclude "/home/user/domain.com/site/excluded-dir2"

GNU TAR:

tar -cvf httpdocs_06_20_2006.tar.gz
--exclude "/home/user/domain.com/site/excluded-dir1"
--exclude "/home/user/domain.com/site/excluded-dir2"
/home/user/domain.com/site

Or

tar -zcvf httpdocs_06_20_2006.tar.gz -X a_list_of_exclude_path.txt /home/user/domain.com/site

Friday, June 12, 2009

Improving Drupal's page loading performance

Improving Drupal's page loading performance

Article published on January 30, 2008

Introduction

Google dominates the search engine market for a large part thanks to its spartan, no-bells-nor-whistles interfaces. But also thanks to its incredible speed (which is partially thanks to that spartan interface, of course).

Since you're reading this article, you're probably a Drupal developer. It's pretty likely that you've had some visitors of your Drupal-powered web site complain about slow page load times. It doesn't matter whether your server(s) are shared, VPSes or even dedicated servers. Visitors that live abroad – i.e. far from where your servers are located – will face the same performance issues, but at even worse scales.

This article is about tackling these issues.

Front-end performance

Faster servers with more memory stop improving your web site's performance at some point. Yet, even before your web site gets big, there are other places to look at to improve performance, where greater effects can be achieved, even at lower costs – significantly lower costs actually. Typically, less than 20% of the total response time is used to retrieve the HTMl document. That means the other 80+% is used to process what's in the HTML file: CSS, JS, images, videos. And in many cases, that number is even higher.

Depending on your website, your server(s), et cetera, these optimizations will probably shave off between 25 and >100 percent (estimated) of your page loading time. Initial (empty cache) and consecutive page loads (primed cache) will both be significantly faster, unless you've already done your own round of optimizations.

Much thanks go to Yahoo!'s research that resulted in fourteen rules and the accompanying YSlow tool (we'll get to that in a second) that allows you to check how your web site performs according to those rules. If you can apply all fourteen successfully, your web site should fly. (Assuming that your page generation times aren't super slow, of course.) As always, more optimizations are still possible. I'll discuss some very effective ones briefly at the end.

YSlow

First things first: make sure you've installed Firefox, Firebug and YSlow for Firebug (version 0.9 or better).

Firebug is simply a must-have for any web developer, it doesn't matter whether you're a professional or an amateur. YSlow is a Firefox add-on developed by Yahoo!, that analyzes your web page and tells you why exactly (remember those fourteen rules?) your site is slow (hence "y-slow", which is pronounced as "why slow"). But at the same time, it tells you how you can fix those pain-points. The lower the rule number, the greater the effect.

What follows is a comprehensive, yet pretty complete review of how Drupal 5 and 6 score on each rule, by listing the required features, settings or guidelines.

If you want to skip the information and want to see results, just skip to the part where I explain how you can apply the optimizations to your site.

Rule 1: Make fewer HTTP requests

Requirement

Drupal 5

Drupal 6

CSS aggregation

yes

yes

JS aggregation

no

yes

Generate CSS sprites automatically

no

no

Drupal even has the ability to compress CSS files (through stripping comments and whitespace). JS aggregation has been added in Drupal 6. To my knowledge, not a single CMS/CMF ships with the ability to generate CSS sprites. Nor does a single one have a module or extension that allows them to do so. This could be a Drupal key performance feature, if it were supported.

Solution

The easiest way to reduce this significantly is to enable Drupal's CSS and JS aggregation. You can find these settings at admin/settings/performance in your Drupal site.

If you're using Drupal 5, there's a backport of Drupal 6's JS aggregation feature, you can find it in this issue – I sponsored this patch.

There is not yet an automatic CSS sprite generator module for Drupal. If your site is styled pretty heavily, this would benefit you even more than CSS and JS aggregation. I hope somebody – or some Drupal company – will take the initiative.

In the mean time, there's a free CSS Sprite Generator out there, if you don't mind doing it manually.

Rule 2: Use a CDN

Requirement

Drupal 5

Drupal 6

Alter URLs of served files dynamically

no

no

Drupal's File API needs work: it should be trivial to alter file URLs dynamically, e.g. based on the file size or type of a file.

Solution

I chose to tackle this particular problem myself, because using a CDN greatly enhances the usability of your web site for visitors that live far away from your servers. And one of the projects I'm working on, is one with a very international audience.

The first part of what's needed, is obviously to update Drupal core to support file URL altering. I chose to create a new function, file_url(), through which all URLs for files should be generated, including the URLs for additional CSS files in the page.tpl.php file (e.g. for a print.css file). This patch also provides a new hook: hook_file_server(), through which modules can provide new file servers. To configure the preferred file server, a new "File servers" setting has been added to the File system settings form. If one server can't serve a file, Drupal will try the second server, and so on. It will always fall back to the web server Drupal is being served from if all servers provided by modules failed.

Currently, I've only got a Drupal 5 patch (it's included in the CDN integration module and attached at the bottom of this article), because I want to get more feedback before I start maintaining patches for 2 different versions of Drupal. As soon as the patch ends up in its final form, I will provide a Drupal 6 patch, and of course push for Drupal 7 inclusion. An issue at Drupal.org has been created.

The second part – integration with a CDN – obviously requires an implementation of hook_file_server(). So the CDN integration module was born. It's written with flexibility in mind: it supports synchronization plugins (currently ships with one: FTP), can create unique filenames or directories (necessary if you don't want to break relative paths), provides the tools to check whether your filters are working well (per-page and site-wide statistics) and the filters can be configured using parameters similar to Drupal's file_scan_directory() function.

An article that includes benchmarks of the effects of the CDN integration module is being worked on. The same article will include a complete installation tutorial as well.

Rule 3: Add an Expires header

Requirement

Drupal 5

Drupal 6

Don't set the Expires header for web pages

yes

yes

Set the Expires header for all other files

yes

yes

Allow far future Expires headers: ability to alter URLs of served files dynamically

no

no

By setting the Expires header for files, you tell the browser that it's ok to cache them.

Drupal sets the "Expires" header for all other files than web pages to 2 weeks. This is sufficient for most uses. For maximum performance, this should be set to a date in the far future (e.g. 10 years from access), but this requires unique filenames: each time the file is updated, the filename should change as well this is why file URL altering is a requirement. If not, your users could still be using the old files, since they may be in their cache.

Solution

Changing the future date for the Expires headers is easy enough: simply edit your .htaccess file. Your Apache server must also have mod_expires installed, this is available by default on most servers. However, making filenames unique is an entirely other matter. The altering of file URLs is already solved in the solution for rule 2. So all you have to do now, is implementing a file server that supports this. The aforementioned CDN integration module provides this feature, but if you want to use it, you of course have to use a CDN.

Rule 4: GZIP components

Requirement

Drupal 5

Drupal 6

GZIP web pages

yes

yes

GZIP CSS and JS files

no

no

When Drupal's page caching is enabled, pages are written to the cache in GZIPped form! To learn more about how Drupal handles GZIPping, run this command from your Drupal root directory:

egrep ‑rn "gzip" .

Don't forget the dot at the end!

However, Drupal does not yet allow you to gzip CSS and JS files.

Solution

A Drupal core patch for this is being worked on, but has unfortunately been inactive for quite some time.

If you are using my CDN integration module, you don't need to worry about this, since CDNs GZIP files by default, if the client supports it.

Alternative solution

As an alternative, you could configure your Apache server to automatically compress files.

An example for Apache 2.x: add the following lines to your .htaccess or httpd.conf file:

AddOutputFilterByType DEFLATE text/css application/x-javascript

Rule 5: Put CSS at the top

Requirement

Drupal 5

Drupal 6

Abstraction to add CSS files to the web page

yes

yes

Default location in the XHTML document is the  tag

yes

yes

Drupal has this abstraction: drupal_add_css().

Putting stylesheets to the document HEAD makes pages load faster: it allows the page to be rendered progressively.

Rule 6: Put JS at the bottom

Requirement

Drupal 5

Drupal 6

Abstraction to add JS files to the document

yes

yes

Default location in the XHTML document is just before

no

no

Drupal has this abstraction as well: drupal_add_js().

JS should be at the bottom, because browsers wait until everything in the  tag has loaded. As you probably know, JS files tend to be pretty large these days, so loading them might take a while, thus postponing the rendering of the page. If you'd put the JS files at the bottom, then your page can be rendered while the JS files are still loading! It also achieves a greater download parallelization, thus cutting down your overall page loading time.

This is also being discussed at groups.drupal.org.

Solution

Unfortunately, the default value for the $scope parameter of drupal_add_js() is bad: 'header'. If we simply make 'footer' the default, we're good. The number of contributed modules that sets this to 'header' explicitly, is very low, so it shouldn't be too much work to convert these. And I've yet to encounter the first module that has issues with being at the bottom instead of the top.

A more complex part of the solution are Drupal's default JS files: misc/jquery.js and misc/drupal.js. These can be put in the footer without any issues whatsoever. But what if a contributed module chooses to put its files in the header? Then they may not yet be loaded! For maximum compatibility, we should add the default JS files to the header if at least one module chooses to add its JS file to the header.

I've attached patches for both Drupal 5 and 6, but neither implement the more complex part I just explained. In my opinion, Drupal should enforce a strict policy: all JS files should be "footer-compatible". Until somebody can point me to some JS that must be in the header to work properly, I'm unlikely to change my opinion about this proposed policy.

Alternative solution

The second method to fix this, doesn't involve hacking Drupal core, but is also more hassle since you have to repeat it for every theme you're using. Suppose you're using the default Drupal core theme, Garland. Then open the themes/garland/page.tpl.php file in your favorite editor. Find this line at the top of the file:

   

Cut it away from there, and put it just before this line at the bottom:

   

So your end result should look like this:

          

As you can see, it now comes just before the closing  tag. (Well, also before the $closure output, which is the output generated by all hook_footer() implementations.)

Rule 7: Avoid CSS expressions

Requirement

Drupal 5

Drupal 6

No default theme should implement it

yes

yes

CSS expressions are not recommended, because they're evaluated many times: when the page is rendered or resized, but also when the page is scrolled. Even when the user moves the mouse over the page!

None of the Drupal core themes uses CSS expressions. Just make sure you don't use it in your own themes.

Rule 8: Make JS and CSS external

Requirement

Drupal 5

Drupal 6

Inline CSS and JS should be avoided or used sparingly

yes

yes

If your web site is a common homepage for many users, you may want to use a custom strategy and read this. Otherwise, you can ignore this rule without worrying.

Rule 9: Reduce DNS lookups

Requirement

Drupal 5

Drupal 6

Use 2-4 hostnames by default: ability to alter URLs of served files dynamically

no

no

To my knowledge, not a single hosting provider offers a static file server by default. So it makes a lot of sense that Drupal doesn't do it by default. However, Drupal should support it out-of-the-box.

If you use a lot of so called widgets (those small blocks of content provided by Flickr, del.icio.us, MyBlogLog, and so on) on your site, you'll have some extra work to do.

Solution

The altering of file URLs is already solved in the solution for rule 2. So, once again, all you have to do now, is implementing a file server that supports this.

If you use my CDN integration module, then you'll be using 2 hostnames or more, but this of course requires you have access to a CDN.

Alternatively, you can use a static file server. Robert Douglass' article on using Drupal with a static file server is a very complete reference: from the pros and cons to the entire server setup.

See Yahoo's documentation for more details.

Widgets solution

If you're using a lot of widgets and you want to continue using them, you can. The solution is simple: cache as much as possible on your own site (or to your CDN).

For example, if you use Google Analytics, make sure you've installed the Google Analytics module, which has an option to cache the .js file locally (and update it once each day, to make sure you're serving the latest version).

Rule 10: Minify JavaScript

Requirement

Drupal 5

Drupal 6

JavaScript minification

no

no

This was originally included in Drupal 6 core. However, it has been removed because it was problematic; it would result in boatloads of JS errors, and thus the JS would simply stop working. The technique used by Drupal 6 was Dean Edwards' packer, also nicknamed packer.

Solution

Packer, isn't just a minifier, it's also an obfuscator. A minifier only strips whitespace and comments, but an obfuscator also munges the code; it renames variable and functions as short as possible. For this, the packer uses a reduction algorithm (hence its name). However, this has serious consequences for the page loading time as well: it can easily take 200 ms to unpack the JS! Additionally, the effectiveness of GZIPping packed JS files is much lower.

More reliable alternatives are JSMIN (minifier/uglifier), Dojo Shrinksafe (minifier/obfuscator) and YUI Compressor (minifier). The last two are built on top of Rhino, Mozilla's Javascript engine, written in Java. Therefor neither qualify for Drupal core inclusion. A JSMIN PHP implementation exists, so I think this is the best choice.

There's an issue to add this to Drupal 7.

Rule 11: Avoid Redirects

Requirement

Drupal 5

Drupal 6

Avoid redirects by default

yes

yes

Drupal could redirect users accessing the non-aliased URL /node/11 to the aliased version /about, but it does not – at least not by default.

The Global Redirect module implements this feature in a sensible way. See the project page for a complete explanation.

Rule 12: Remove Duplicate Scripts

Requirement

Drupal 5

Drupal 6

Abstraction to add JS files to the document

yes

yes

Drupal has this abstraction, as mentioned in rule 6: drupal_add_js(). You then just use a static variable to prevent adding the same file multiple times. For an example, see the jCarousel module.

Rule 13: Configure ETags

This is the only rule that depends completely on the server setup. An ETag uniquely identifies a file, and is used to verify if the file in the browser's cache matches the file on the server.

The problem is that they are generated using attributes specific to the server (inodes) they're being served from. This implies that when, for example, you're using multiple servers behind a load balancer, you may one time be accessing the files from server 1, another time the files from server 2. And since the ETags don't match, you'll be downloading the file again!

Solution

If you're using multiple servers, disable ETags. For Apache users: add this line to your httpd.conf:

FileETag none

IIS users have to follow a more complex procedure.

Alternative solution

Use a single server to serve files, or a CDN. See the solutions for rules two and nine for detailed information.

Rule 14: Make Ajax Cacheable

Requirement

Drupal 5

Drupal 6

Pluggable render formats

no

no

Ability to set GZIP-ability per format (i.e. rule 4)

no

no

These feature was being worked on for Drupal 6, but unfortunately wasn't ready in time.

The ability to set the GZIP-ability per output format (i.e. rule 4) should be handled at in the same patch, or in a follow-up, since it affects the performance of AJAX callbacks so much.

Other - but mostly less important - rules that are implemented automatically: rules 9 and 13 (AJAX responses will be served from the same server as Drupal), rule 11 (redirects are extremely unlikely to be used for AJAX callbacks in Drupal). Rule 10 is almost completely irrelevant, because GZIPping JSON data has a much greater effect.

Solution

The node rendering refactoring issue is listed for the Drupalcon Boston 2008 code sprint, so we'll probably see this in its final form in a couple of months.

Applying this to your site

This is of course a boatload of information. The easiest way to apply all of it to your site, is by installing my CDN integration module, and using the included Drupal core patch that also adds JS aggregation and puts JS files at the bottom (by changing the default scopes).

Live sites

Before you start applying this to your site, you of course want some proof that all these optimizations do indeed have an effect. No problem. You're looking at it. This page should have been loaded in less than a second. Subsequent page loads should complete in less than half a second. With Drupal's page caching disabled (!), eAccelerator installed and a MySQL query cache in place.

Another live site is DrupalBin. That site is running on a shared server (DreamHost), without eAccelerator and without a MySQL query cache – which explains the often slow page generation times.

Additional optimizations

In order of effectiveness:

The Boost module enables Drupal to perform static page caching. This means that rendered pages are written to files, and through some mod_rewrite magic, it will serve the statically cached page from the file if it's available, thus without even a single DB query!

This article at 2bits is chock full with Drupal performance tips.

The core patches module Advanced cache, again by Robert Douglass, provides caching for blocks, comments, the forum structure, built nodes, path lookups, popular search queries and taxonomy trees.

Drupal issues

#101227: GZIP aggregated CSS and JS, by Owen Barton (Grugnog2) and Ted Serbinski (m3avrck).Has some patches, but is out of sync.

#210447: Introduce Javascript compression, by Nedjo Rogers (nedjo). Doesn't have patches yet.

#134478: Refactor node rendering, by Jeff Eaton (eaton) et al.

#214934: file_url() and hook_file_server(), by Wim Leers.

More information

High Performance Web Sites (video of presentation), by Steve Souders.

Explains all YSlow rules in detail.

CSS Sprites: Image Slicing’s Kiss of Death, by Dave Shea, A List Apart.

Explains the need for CSS sprites, how they work and the pittfalls.

CSS Sprites: How Yahoo.com and AOL.com Improve Web Performance, websiteoptimization.com.

Case-study that may be interesting if you're learning about CSS sprites.

CSS Sprite Generator Tool, by Stuart Colville, Muffin Research Labs.

Announcement of the aforementioned CSS sprite generator.

Announcing SilkSprite: A CSS Sprite Plugin for Blueprint, by Don Albrecht, Ajax Bestiary.com.

Automatic CSS sprite generator for the Blueprint CSS framework.

Performance Research, Part 2: Browser Cache Usage - Exposed!, by Tenni Theurer's, Yahoo! User Interface Blog.

Aptly describes why it's important to not forget about page views with an empty cache.

Serving JavaScript Fast, Cal Henderson, Vitamin.

A pretty complete reference on how to serve GZIPped CSS and JS files.

Gzip Your Minified JavaScript Files, Julien Lecomte.

A comparison of how well GZIP-able minified JS files are, after using a certain minifier. Also explains why the packer should not be used due to its reduction algorithm.

Static Page Caching for Drupal 4.7, Arto Bendiken.

Announcement of the Boost module.

Page Load Time Worksheet, Tag 1 Consulting, Inc.

This worksheet can help you to isolate and fix bottlenecks affecting your page load times.

Thanks to …

Yahoo! for their work on YSlow.

Greg Knaddison (greggles) for proofreading this article and making several excellent suggestions to make this article more complete.

Attachment

Size

JS at the bottom - Drupal 5.patch

1.08 KB

JS at the bottom - Drupal 6.patch

1.28 KB

hook_file_server - Drupal 5.patch

11.61 KB

Tags

apache

Drupal

page loading performance

performance

61226 reads

Comments

January 30, 2008 - 05:55 — deekayen (not verified)

good job

This is certainly worth a space in my bookmarks.

reply

January 30, 2008 - 07:19 — Jorge (not verified)

Great article! Thank you

Great article! Thank you

reply

January 30, 2008 - 08:27 — Dries (not verified)

Great article

Great article, and careful analysis. I've written about YSlow before (http://buytaert.net/yslow) -- and I have been recommending it to a lot of people. It should be part of the "Drupal development toolchain" that every developer uses.

The Javascript position issue is interesting -- we should enforce good behavior through our APIs and make the required changes. Why would we allow Javascript to be placed at the top of the page?

reply

January 30, 2008 - 15:22 — Ximo (not verified)

In some cases this is needed

AFAIK, loading JS at the bottom should be fine in most cases - jQuery usually works unobtrusively by interacting with the DOM once the document is ready. As long as the jquery.js file is loaded before any jQuery code, there should be no problem.

There are however some situations where you'd want jQuery to do its magic before the document is completely loaded, such as dynamically adding classes to elements to change their appearance. If this has to wait for the bottom of the document to be reached, one would experience an annoying glitch as the code is run. An exampe of this is the plugin to add rounded corners to boxes.

So loading jquery.js and drupal.js in the footer by default, and in the header if a module has added some JS there, sounds reasonable. Themes may add JS directly into tpl.php files, but this is bad practice anyway, one should use drupal_add_js() instead.

Joakim

reply

January 31, 2008 - 09:39 — andremolnar (not verified)

Not quite correct - this has been tested

Please see: http://groups.drupal.org/node/8399#comment-25894

I was under the same impression - but decided to run tests. If you want to manipulate the DOM there is virtually no difference whether you place $(document).ready(function(){//DOM manipulation}) at the top or the bottom of the page. See the link for complete details.

If anyone finds a flaw in the testing method or has some additional insight please share in the thread on g.d.o http://groups.drupal.org/node/8399

andre

reply

January 31, 2008 - 18:39 — ximo (not verified)

Correction

Yea, I corrected myself in that same thread. I was speaking from my own experience and what I've learned from others, but the problems I had may have been caused by something else.

Anyway, loading the required JS files from  if needed would allow the few scripts who depends on this to run as well. One would only have to specify "header" as the scope instead of the (as suggested) default "footer".

Joakim

reply

June 30, 2009 - 08:39 — rtbox (not verified)

you may want to call a

you may want to call a function such as swfobject inline, having the code at the bottom breaks this. I am aware that you can just call the function below the script declaration however this is not really possible if you will be posting into the content of a node.

reply

January 31, 2008 - 21:16 — Wim Leers

Excellent question

That's an excellent question, but I'm afraid I can't answer this yet either.

I've searched a lot, but failed to find any information regarding this rather critical topic. Not even a mention on A List Apart.

I've contacted John Resig about this, asking him to comment here.

reply

February 8, 2008 - 22:33 — Konstantin (not verified)

Why would we allow

Why would we allow Javascript to be placed at the top of the page?

document.write().

reply

January 30, 2008 - 09:00 — Grugnog (not verified)

Wow

What can I say - this is the most complete article I have seen on this topic by far.

Oh if only this (and YSlow!) had existed when I was trying to convince everyone that we needed to aggregate CSS!

Next stop - gzipping for D7 :)

reply

January 30, 2008 - 09:21 — Sina Salek (not verified)

Very very useful

Thanks, very very useful specially the CDN module. good work man

reply

January 30, 2008 - 09:34 — avior (not verified)

Thank you

Thank you for that great work

very informative , and helpfull

reply

January 30, 2008 - 14:32 — Benjamin Melançon (not verified)

Good stuff-- one more resource

Very helpful stuff, Wim!

Here's one more major resource I didn't see listed:

Drupal Performance Agency's checklists and worksheets, see "Documents" on that page: http://tag1consulting.com/drupal/performance

The docs cover some server and MySQL tuning as well as PHP and Agaric in a very systematic way. It was helpful at the right time for Agaric to keep World Social Forum 2008 online.

benjamin, Agaric Design Collective

reply

January 31, 2008 - 21:20 — Wim Leers

Thanks!

I've never heard of that Drupal company, but they seem to have a great team and do great things.

Thanks for the link, I've added it to my more information section.

reply

January 30, 2008 - 14:34 — ximo (not verified)

Great article!

I don't think much more can be said on the topic, and the links are excellent. Great resource for all of us, both n00bs and those who know abit about "frontend" performance :)

Thanks!

Joakim

reply

January 30, 2008 - 14:37 — Gábor Hojtsy (not verified)

rule 3 addendum for Drupal 6

Well, your observation in rule 3 for Drupal 6 is not entirely up to date. The CSS and JS file serving was changed in the RC phase to include a query string which changes on every update.php run and when all caches are flushed. So basically Drupal has a built-in way to 'rename' the URLs for the static CSS and JS files with short query string additions. (BTW this grown out of a bug fix for Garland to show up the new styles and behaviors with Drupal 5 -> 6 upgrades, even though the file names are the same).

reply

January 31, 2008 - 21:41 — Wim Leers

Not quite what's necessary

Although it covers the basics of what is necessary, it's very ineffective, in that it forces a refresh of all files!

Please correct me if I'm wrong :)

(Relevant d.o issue: #199946.)

reply

February 1, 2008 - 00:43 — Gábor Hojtsy (not verified)

you are right

Yes, you are right. Since Drupal cannot afford to check for the dates of all files each time they are served, we don't know about that, so all we can do is to refresh files on upgrades / updates. There is lot of stuff to do here in Drupal 7 and in contribs for Drupal 6.

reply

February 1, 2008 - 01:53 — Wim Leers

Current approach & thoughts

My current approach is to keep an array with source file paths (i.e. the ones that are actually Drupal's web server) as keys and destination file paths (i.e. the ones synced to the CDN) as keys in the variable table. The destination file paths already contain the unique filenames (or unique directory, to not break relative paths for e.g. CSS files).

So, currently, it doesn't scale: if you're working with thousands of files, the size of this array will grow into the megabytes, which is unacceptable. This will have to be reworked to work with DB queries.

But then the same problem as for URL aliases arises: lots of queries per page, but files are typically only in the 5-20 range (with CSS/JS aggregation enabled of course), whereas URL aliases are very often in the >100 range.

We can reduce the number of queries by still putting the most commonly used files in an array.

If there's some info on best practices in this area available, let me know ;)

reply

January 30, 2008 - 18:05 — heyrocker (not verified)

Content Synchronization

This is a fantastic article and I can see a ton of potential uses for the CDN module even above and beyond using it for CDNs. One of the parts of the module that I find most interesting is the content synchronization piece. I work in a situation where we have a dev/qa/production deployment process, and multiple load balanced production servers, so content synchronization is always rearing its head in various forms. Would you consider pulling this functionality out into its own module which is basically a black box for pushing files around? I think there are a lot of uses the community could find for such a module.

reply

January 31, 2008 - 21:47 — Wim Leers

Partially done already by design

This is partially done already: the module supports synchronization plugins. Currently there's only one plugin: FTP.

The part that scans for files that need to be synchronized (based on the filters configured by the user, so highly customizable) are all contained in the pretty small cdn_cron.inc file (320 lines and it contains loads of cron-specific stuff that could be ripped out).

I'll gladly accept patches, but I won't start a separate module for this just yet – plenty of work already with the modules I'm currently (co-)maintaining. If you'd like to sponsor it though, you can contact me.

reply

January 31, 2008 - 00:22 — links for 2008-01-30 &laquo; Mike&#8217;s Blog (not verified)

Pingback

[...] Improving Drupal’s page loading performance (tags: drupal web2.0) [...]

reply

January 31, 2008 - 01:21 — /dev/random :: links for 2008-01-30 (not verified)

Pingback

[...] Improving Drupal’s page loading performance (tags: drupal web2.0) [...]

reply

February 1, 2008 - 04:27 — ultimike (not verified)

Outstanding

Thanks for the great article - this is the by far the most comprehensive guide for tackling all the issues that yslow has been pointing out on all our Drupal-powered sites.

You've done a real service to the Drupal community here.

-mike

reply

February 3, 2008 - 13:55 — Wim Leers

Packer decompression delay

I updated the article with an explanation about the decompression delay due to the way Packer works.

reply

February 4, 2008 - 11:18 — dalin (not verified)

Can't always move $scripts to end

I've got a situation where I can't move $scripts to the end of the document. I've have a site frontpage that uses several jcarousels to scroll through images. There's also a few ad blocks on the page. The adblocks contain a script tag that calls the ad js. That js uses document.write to print code for either an image or flash. Unfortunately this isn't exactly an instantaneous process and in the time it takes for this snippet of html to be generated and sent, the page has already begun to be rendered. If I were to use document.ready for the jcarousels, they wouldn't be formated until the page is completed loading and would cause a flash of styled content (it's fairly significant if you have a lot of styling of this nature). So the solution is to put the jcarousel code imediately after the ul that it styles, and don't use document.ready, just use the jquery function directly. So for this to work the jquery library needs to be loaded before this point, i.e. in the head.

I can see this becoming an increasingly common situation as we see ever more amounts of javascript in everyday webpages.

reply

February 4, 2008 - 19:41 — Wim Leers

Agreed

I agree. Ideally, the changes performed by JS should not affect the display: when JS is enabled, the same "initial view" should be present, through CSS only. This is of course not realistic.

However, your method to prevent flashing (putting the .js files in the HTML head and calling the jcarousel() method immediately after the ul it styles) seems awkward: we don't want inline JS. Isn't putting the JS code in the head of the document itself enough to guarantee a flawless load?

For readers interested in reproducing this issue: see my Mini panels demo, which has a jCarousel.

reply

February 5, 2008 - 02:32 — dalin (not verified)

didn't work for me

Moving the jcarousel code to the header doesn't work for me. This makes sense in my mind since the ul in question doesn't yet exist at this point.

reply

February 5, 2008 - 20:34 — Wim Leers

Please try this …

Please try this:

$('ul#some-id').ready(function() {

  // jCarousel initalization

});

(i.e. use a selector instead of document)

reply

February 26, 2008 - 13:51 — Christian Schmidt (not verified)

ETag on load-balanced Apaches

An alternative to disabling FileETag when running multiple load-balanced Apaches is to let Apache consider only the file size and last modification time when generating the ETag. This is done using the following config line:

FileETag MTime Size

This setting requires that files are copied to the parallel servers in a way that preserves the last modification time (and that files aren't modified several times per second without changing size, but this probably isn't a problem).

reply

February 26, 2008 - 17:21 — Wim Leers

Thanks

Thanks for your addition!

I knew there were ways to preserve ETags, but I deliberately chose to not enter that topic, because that would lead me too far off the focus.

reply

February 26, 2008 - 13:54 — Dan Frost (not verified)

Excellent post

What an excellent post. I was just starting to post something similar but decided against it when reading yours as it covered the topic perfectly. Very useful and well laid out - thank you.

I think it's worth mentioning that Live Search (MSN, whatever) have confirmed that they do use ETags and there are ways of sync'ing ETags in both Apache and IIS when used in a cluster.

There's no evidence (that I can find) that Google use ETags - they play it safe by using If-Modified-Since.

Oh, YSlow can (ironically) slow down your browser (at least it did on mine) so I'd disable it when not using it specifically.

dan

reply

February 26, 2008 - 17:21 — Wim Leers

Indeed

Indeed there are ways to do that. Actually the comment that was posted just before your own describes such a method :)

And indeed, YSlow – like just about any other Firefox add-on – slows Firefox down. I choose to have YSlow and the Web Developer Toolbar enabled at all times, since I use it for web development only. I uninstall all other add-ons.

reply

October 11, 2009 - 00:13 — at yarışı (not verified)

great article

What an excellent post. I was just starting to post something similar but decided against it when reading yours as it covered the topic perfectly. Very useful and well laid out - thank you.

reply

February 28, 2008 - 20:22 — magnum blog &raquo; Blog Archive &raquo; links for 2 (not verified)

Pingback

[...] Improving Drupal’s page loading performance | Wim Leers (tags: drupal performance optimization articles css howto yslow) [...]

reply

March 4, 2008 - 12:15 — Alan F. (not verified)

Thanks for this excellent

Thanks for this excellent post and analysis.

Specially for "Solutions".

reply

March 21, 2008 - 19:26 — Wim Leers

Yahoo! posted 20 additional optimization rules

Yahoo! posted 20 additional optimization rules on. They'll provide an in-depth explanation later, but it's interesting already. See http://developer.yahoo.net/blog/archives/2008/03/yahoos_latest_p.html.

reply

May 22, 2008 - 05:22 — IceCreamYou (not verified)

I've been wondering how to

I've been wondering how to improve my YSlow score for awhile, since most of the things YSlow tells me aren't modify-able for anyone who isn't really capable of tampering with PHP and .htaccess files. This article should help. Thanks!

reply

May 26, 2008 - 03:41 — Timmy Carter (not verified)

thank you ! great article

thank you ! great article !

really helpfull

reply

July 23, 2008 - 20:46 — Sienna (not verified)

nice

It really works great as well. Drupal is getting better and better. thanks

reply

May 26, 2008 - 12:33 — Pedro Pablo (not verified)

improvement for css and js aggregation

Great and useful article. The definitive guide!! :-)

for your info, recently a simple and smart module to compress css and js files has been published at drupal.org. The name is Smartcache and author's nick is Gremlinc5.

I have tested it and works fine, and you don´t have to tweak any core files, just add a .htaccess rule and a couple of files. Worths a look as maybe it has a place in your article.

reply

May 29, 2008 - 18:37 — DIGG FRANCE (not verified)

Is Digg-France slow to load ?

Hi,

Please can you confirm that my website is very slow to load ?

http://www.digg-france.com/

It's a Drigg module based websites and it seems quite slow.

Thanks.

ps: maybe you should add the comment_subscribe module for you site ;-)

reply

June 13, 2008 - 09:04 — PenCake &raquo; Blog Archive &raquo; Drupal Related (not verified)

Pingback

[...] Improving Drupal’s page loading performance | Wim Leers [...]

reply

June 23, 2008 - 18:19 — lsabug (not verified)

I want to cache images but default sets header to 1978

I've gone through your recommendations (can't afford CDN) and my nagging problem is that drupal never seems to cache any of my images saved above root (private files structure). I have it set to cache images in my .htaccess file and I have mod_deflate, mod_expires and mod_headers enabled in apache.

YSlow shows says images on my front page do not have a far future Expires header:

(11/19/1978) http://dev.domain.org/system/files/admin/pconnectAd.gif

I know the default for headers in bootstrap is 1978 for content but how do I change for my private image files?

Here's my htaccess:

# Requires mod_expires to be enabled.

  # Enable expirations.

  ExpiresActive On

  ExpiresDefault "access plus 2 years"

  # Do not cache dynamically generated pages.

  ExpiresByType text/html A1

  # Set up 10 year caching on commonly updated files

 

  ExpiresDefault "access plus 10 years"

 

 

  # Set up 10 year caching on commonly updated files

 

  ExpiresDefault "access plus 10 years"

 

  # Force no caching for dynamic files

 

  ExpiresActive Off

 

More information: http://drupal.org/node/272082

Any and all suggestions will be appreciated : )

reply

July 17, 2008 - 06:18 — rosedragon (not verified)

thank you

Thank you for your tutorial. I had use YSlow and tweak common.inc into JS at bottom and CSS at top. While drupal run module CSS at top, theme CSS at bottom, I change it viceversa, since I dont use any important CSS with module.

About the run module/theme CSS, I edit the value on if (!$preprocess && $type == 'theme') , like these:

          // If a CSS file is not to be preprocessed and it's a module CSS file, it needs to *always* appear at the *top*,

          // regardless of whether preprocessing is on or off.

          if (!$preprocess && $type == 'theme') {

            $no_module_preprocess .= ''."\n";

          }

          // If a CSS file is not to be preprocessed and it's a theme CSS file, it needs to *always* appear at the *bottom*,

          // regardless of whether preprocessing is on or off.

          else if (!$preprocess && $type == 'module') {

            $no_theme_preprocess .= ''."\n";

          }

Now, what I should do is to minimize the usage of images of my CSS.. since it use like useless 11 css images.

reply

August 9, 2008 - 13:34 — Improve Drupal performance &laquo; chirale (not verified)

Pingback

[...] Improving Drupal’s page loading performance [...]

reply

August 10, 2008 - 20:29 — chirale (not verified)

CSS Sprites modules

I never try it, but there's a CSS sprites generator module for Drupal 5.x:

http://drupal.org/project/sprites

reply

August 15, 2008 - 07:35 — xtfer (not verified)

Both FCKEditor and Google

Both FCKEditor and Google Analytics may choke if the JS is placed at the bottom, in their current state. What about placing the $scripts tag just inside the body tag?? What potential issues might this cause? Would it be an improvement?

reply

September 15, 2008 - 19:57 — zuborg (not verified)

On-line site performance testing tool

I would also recommend this online free tool: http://site-perf.com.

It measure loading speed of page and it’s requisites (images/js/css) like browsers do and shows nice detailed chart - so you can easily spot bottlenecks.

Also very useful thing is that this tool is able to verify network quality of your server (packet loss level and ping delays).

reply

September 23, 2008 - 14:49 — GoldNumber (not verified)

Improvements in 3 times

Thanks for your arcticle. It helped me improve my site performance in more then 3 times.

The only problem for me now is improving internal Drupal performance such as page loading for authenticated users.

reply

September 24, 2008 - 23:03 — Drupal Developer's Toolbox | Developer's Tool (not verified)

Pingback

[...] Improving Drupal’s Page Loading PerformanceLooking to speed up a Drupal website? Try following these steps. [...]

reply

September 25, 2008 - 01:26 — drupal malaysi (not verified)

will pay attention

great article, and we are going to start paying attention on this, especially the usage of YSlow. BTW, http://wimleers.com is not using CDN? It was listed as an example in CDN module?

reply

September 25, 2008 - 15:11 — Wim Leers

You have to add

You have to add wimleers.cachefly.net as the CDN used on the web site, then it'll increase the score. The CDN module is not yet ready for production use though. I'm also having a server issue because of which new files haven't synced yet at the moment of speaking, causing a couple of files not to be served from the CDN.

reply

September 25, 2008 - 06:58 — Drupal Developer’s Toolbox (not verified)

Pingback

[...] Improving Drupal’s Page Loading PerformanceLooking to speed up a Drupal website? Try following these steps. [...]

reply

September 25, 2008 - 10:10 — Drupal Developer’s Toolbox | POLPDESIGN (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Looking to speed up a Drupal website? Try following these steps. [...]

reply

September 26, 2008 - 01:04 — Vieno (not verified)

Pingback

[...] Improving Drupal’s Page Loading PerformanceLooking to speed up a Drupal website? Try following these steps. [...]

reply

September 26, 2008 - 02:15 — Drupal Developer’s Toolbox | rafdesign (not verified)

Pingback

[...] Improving Drupal’s Page Loading PerformanceLooking to speed up a Drupal website? Try following these steps. [...]

reply

September 26, 2008 - 16:08 — Drupal Developer’s Toolbox (not verified)

Pingback

[...] Improving Drupal’s Page Loading PerformanceLooking to speed up a Drupal website? Try following these steps. [...]

reply

September 26, 2008 - 16:08 — Drupal Developer’s Toolbox (not verified)

Pingback

[...] Improving Drupal’s Page Loading PerformanceLooking to speed up a Drupal website? Try following these steps. [...]

reply

September 26, 2008 - 20:33 — Drupal Developer’s Toolbox | ONGUIDESNET (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Looking to speed up a Drupal website? Try following these steps. [...]

reply

October 7, 2008 - 09:24 — xzhang (not verified)

Very good article! Thanks

Very good article! Thanks

reply

October 9, 2008 - 17:34 — For Drupal Developers - TechAdmin's Soul Asylum (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Bạn đang tìm cách tăng tốc cho các trang web của mình? Đây là cách giải quyết dành cho bạn. [...]

reply

October 15, 2008 - 08:53 — Drupal Developer's Toolbox | Mind Tree (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Looking to speed up a Drupal website? Try following these steps. [...]

reply

October 17, 2008 - 19:42 — Drupal Developer’s Toolbox (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Looking to speed up a Drupal website? Try following these steps. [...]

reply

October 17, 2008 - 22:13 — Anonymous (not verified)

Smart Optimizer

I've found that a PHP library called Smart Optimizer works well with Drupal.

http://farhadi.ir/works/smartoptimizer

It automatically minifies, concatenates, and gzips CSS and JS and caches the resulting files to serve future requests. Super easy to setup as well - just copy the directory to your server and paste a snippet in you htaccess file. Makes a huge difference in Yslow.

reply

October 22, 2008 - 19:57 — Anonymous (not verified)

Re putting .js files in footer

Great resource BTW!

I used your alternative suggestion and amended my theme to put the .js files at the bottom of the page. However it appears that this breaks FCKEditor, the editor simply does not show up! When I reverted to putting .js files in the header it worked again!

I'm using Drupal 6

reply

October 25, 2008 - 22:37 — HGH (not verified)

Excellent Article

Man that was awesome. Going to bookmark it. Will refer to it often. Thanks!

reply

December 17, 2008 - 06:21 — Mikhailov Anatoly (not verified)

mod_deflate

Mod_deflate in apache2 is pretty much the same as mod_gzip in apache1.3, and mod_deflate is included with the apache2 source package. Both modules allow compressing of the apache server on the fly

http://railsgeek.com/2008/12/16/apache2-httpd-improving-performance-mod_...

reply

December 26, 2008 - 04:05 — under construction | spiffy [d] :: blog (not verified)

Pingback

[...] # [...]

reply

December 29, 2008 - 19:29 — Speed Reading Course Review (not verified)

Very good tutorial

An excellent tutorial!

I learned a lot from this. Thanks so much.

reply

January 8, 2009 - 22:11 — Zane Rokklyn (not verified)

Proof in the pudding?

Great advice! And I like how you challenge us to try loading the page to see how your tips work on your own site. Unfortunately, when I run Yslow on this page, it get this:

Performance Grade: C (71) Expand All Collapse All

D 1. Make fewer HTTP requests

F 2. Use a CDN

B 3. Add an Expires header

D 4. Gzip components

B 5. Put CSS at the top

A 6. Put JS at the bottom

A 7. Avoid CSS expressions

n/a 8. Make JS and CSS external

A 9. Reduce DNS lookups

C 10. Minify JS

A 11. Avoid redirects

A 12. Remove duplicate scripts

F 13. Configure ETags

Time to revisit your own advice? :-(

reply

January 8, 2009 - 22:56 — Wim Leers

Temporary lack of pudding

I stopped using my CDN provider because it turned out they had very few PoPs and for that, I was no longer willing to pay. So it's simply because I'm no longer using a CDN. This is temporary.

I'm in my exam period currently, so I don't have the time to test with another CDN.

I'll fix it ASAP :)

reply

January 15, 2009 - 15:01 — site development log | spiffy[d] (not verified)

Pingback

[...] # [...]

reply

January 20, 2009 - 05:09 — For Drupal Developers &laquo; Web for Dummies&#8217; (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Bạn đang tìm cách tăng tốc cho các trang web của mình? Đây là cách giải quyết dành cho bạn. [...]

reply

February 9, 2009 - 00:57 — Rob Loach

JavaScript Aggregation

A small note that the JavaScript Aggregator module for Drupal 5 will aggregate the JavaScript for you. In Drupal 6, the JavaScript Aggregator module will use JSMin to compress/minify the aggregated JavaScript.

reply

February 9, 2009 - 16:33 — Wim Leers

Yep, that's new since I

Yep, that's new since I wrote this article :)

I will probably post an updated version of this article in a couple of weeks.

reply

February 26, 2009 - 11:42 — Florian Sievers (not verified)

JS in the Footer (unable to apply database updates)

I Just wanted to update my drupal from D6.9 to D6.10. Befor I startet the required database update, I reapplied the patch for JS in the footer (manually, because common.inc have been changed).

If "function drupal_add_js" had been changed to insert the JS in the footer, the database update can't be applied, because the script, that shows the progressbar, won't run.

Solution: First update the database and than patch common.inc. Whenever you need to update the database (e.g. after module update), you must change common.inc to include JS in the header, and after that, you can reapply the patch.

reply

March 2, 2009 - 23:48 — Ethos Blog &raquo; Drupal - A Quick Start up to Drupal (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Looking to speed up a Drupal website? Try following these steps. [...]

reply

March 24, 2009 - 22:35 — mikeytown2 (not verified)

Rule 4: GZIP components

Been working with Rob Loach and his Javascript Aggregator now gzip's javascript. Based off of our work, I released CSS Gzip. No hacking of core required!

reply

March 25, 2009 - 00:27 — Wim Leers

Great job!

I already noticed. Great work :) I'm sure it'll be appreciated by many Drupal users!

reply

March 25, 2009 - 11:11 — Оптимизируем Drupal | CMS - Content Managment Systems (not verified)

Pingback

[...] ниже расположен перевод заметки “Improving Drupal’s page loading performance”, в которой рассматриваются прикладные методы [...]

reply

March 28, 2009 - 13:39 — Tổng quan về Drupal - CỘNG ĐỒNG PKC | PLEIKU - GIA LAI (not verified)

Pingback

[...] hệ thống là một khía cạnh rất quan trọng. Hãy tìm hiểu từ bài viết này. Improving Drupal’s Page Loading Performance Bạn đang tìm cách tăng tốc cho các trang web của mình? Đây là cách giải quyết [...]

reply

April 1, 2009 - 03:01 — Article translated into Russian and selected by Drupal Fire (not verified)

Pingback

[...] article "Improving Drupal's page loading performance" – definitely my most popular writing thus far, bookmarked almost 350 times on delicious – has [...]

reply

April 1, 2009 - 10:34 — Anonymous (not verified)

Help to improve loading performance ?

Hi,

We are still trying to improve our Drigg based website http://www.digg-france.com .

Does anybody here could help? Please tell us what could be done to our digg-like and how much work it would need and cost ?

Thanks a lot.

http://www.digg-france.com

reply

April 8, 2009 - 18:34 — Robert Finale (not verified)

I need some improvements

It's so slow for me, so hopefully this helps.

reply

May 7, 2009 - 16:07 — matt (not verified)

Sprite generator offset options?

for the css sprite generator, what do the offset options do, besides make the image bigger? Is there any reason the offset shouldn't be as little as possible? (The sprite generator doesn't accept an offset of zero, though I don't understand what the problem would be.)

reply

May 13, 2009 - 00:50 — Roger (not verified)

Rule 6: Javascript at bottom breaks site

I installed the Javascript Aggregator module and it works great. Page load times are significantly improved. But when I tried to implement Rule 6, I had a problem.

The site makes heavy use of the Gmap module, with most of the pages featuring a Google map. When I tried to move the print $scripts ?> line to the bottom of the page, all of the maps disappeared, exposing the 'Javascript is required ... ' message. Returning the scripts to the  corrected the problem. (Drupal version 5.17)

reply

June 21, 2009 - 19:05 — Anonymous (not verified)

I just wanted to say that

I just wanted to say that this script has really helped improve the general performance (and YSlow score!) of my company's Joomla site. I also wanted to say thanks. My Drupal 6.2 site's YSlow score improved from 69 to 81.

Keep up the good work. Cheers.

reply

June 23, 2009 - 06:01 — OUVYT » Blog Archive » Daily Del.icio.us (not verified)

Pingback

[...] Improving Drupal's page loading performance | Wim Leers [...]

reply

June 29, 2009 - 00:48 — More About Drupal | depiak (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Looking to speed up a Drupal website? Try following these steps. [...]

reply

July 3, 2009 - 23:06 — Anonymous (not verified)

Huge article, thanks !

Huge article, thanks !

reply

July 29, 2009 - 12:14 — Drupal 性能加速教程 | CMS网 (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Tagged with: 文章索引模板 [...]

reply

August 19, 2009 - 00:20 — Improving Drupal&#8217;s page loading performance | Wim (not verified)

Pingback

[...] View original post here: Improving Drupal’s page loading performance | Wim Leers [...]

reply

August 26, 2009 - 18:19 — Anonymous (not verified)

Info on the webpage

Thank You for the article. I am still reviewing it.

I have a minor issue request. Could you tell me how you were able to add the "TAGS" option at the end of the article block where there are " apache Drupal Page loading performance performance " tag links.

reply

August 27, 2009 - 00:39 — Wim Leers

Simple: through theming, in

Simple: through theming, in node.tpl.php :)

reply

September 21, 2009 - 17:26 — Dan (not verified)

Great article

Really useful and definitely worth bookmarking. Now to get my head round how to implement some patches!

reply

September 28, 2009 - 08:28 — danreb (not verified)

Thanks!

I applied some of the information written here to optimize my drupal site http://www.thecapulenos.com . The only thing I can't apply is the CDN module integration, but it improves much website performance so I'm happy with it.

reply

October 3, 2009 - 05:54 — Drupal Developer’s Toolbox | 9Tricks.Com - Tips - Tricks - (not verified)

Pingback

[...] Improving Drupal’s Page Loading Performance Looking to speed up a Drupal website? Try following these steps. [...]

reply