|
我有一個在linux服務器上用cakephp編寫的網(wǎng)站.我的css和js文件的下載時間非常慢,我遇到了問題.例如,在加載我的主頁時,這就是chrome中的網(wǎng)絡選項卡:

如您所見,我的一個css文件花了59秒下載!重要的是要注意它并不總是相同的css文件.有時它的JS文件,有時是其他css,但它們必須在顯示頁面的其他內(nèi)容之前下載,因此它們會阻止頁面加載.由于等待下載該文件,因此網(wǎng)站不會顯示59秒.
我檢查了我的服務器,它的負載非常低,cpu運行10%,并且使用的ram不到20%.它是一個帶有以下prefork設置的apache服務器:
StartServers 10
MinSpareServers 10
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 10000
這提到的下載時間很慢,網(wǎng)站上可能有3-4個同時用戶.我在AppM下使用appdynamics我的應用程序,沒有任何可疑的顯示在那里.我用服務器管理員檢查了php.ini文件,一切似乎都很好.我可以使用哪些其他軟件來查找此問題的來源? apache日志中的信息也不多.
任何建議將不勝感激
編輯:
我將所有資產(chǎn)都移到了webroot,并在另一個使用同一服務器的域上獲得了這些結果:

正如您所看到的,這次它的jquery文件需要27秒才能下載.它存儲在app / webroot中 解決方法:
Ill take a look at serving assets from webroot
始終將公共資產(chǎn)放在webroot中.
From the book(重點補充):
It’s a well known fact that serving assets through PHP is guaranteed to be slower than serving those assets without invoking PHP. And while the core team has taken steps to make plugin and theme asset serving as fast as possible, there may be situations where more performance is required. In these situations it’s recommended that you either symlink or copy out plugin/theme assets to directories in app/webroot with paths matching those used by CakePHP.
- app/Plugin/DebugKit/webroot/js/my_file.js becomes app/webroot/debug_kit/js/my_file.js
- app/View/Themed/Navy/webroot/css/navy.css becomes app/webroot/theme/Navy/css/navy.css
根據(jù)許多因素,“較慢”可以介于幾乎不可察覺到幾乎無法使用的任何地方.
此建議不是特定于版本的,并且?guī)缀蹩偸沁m用.為了加快資產(chǎn)加載速度,讓網(wǎng)絡服務器為您處理這些問題. 來源:http://www./content-1-197951.html
|