Google 網上論壇首頁
說明 | 登入
群組資訊
會員: 10847
活動: 高度活動
語言: 英文
群組類別:
電腦資訊 > 軟體
電腦資訊 > 程式設計
電腦資訊 > 網際網路
更多群組資訊 »
Optimizing Cake's Performance    

Some general tips on increasing the speed of queries and decreasing page load times.

 

Database Configurations

  • Optimize Indices

    Indexing all foreign keys allows relational queries to run much faster.

  • Index search fields

    If users commonly search 'product names' you may want to build your own query using the command 'MATCHES'. Matches works in the SQL differntly than LIKE and will only return rows if the search is not in more than half of the records. Simple words like a and or etc., are basically ignored because they are too common. 

    If you take this approach, make sure that the field uses a FULLTEXT index. This will make searches much faster.

 

General PHP Configurations

  • Compress output

    • In your php.ini file;

      output_buffering = 1
      output_handler = ob_gzhandler

 

Cake 1.1 Configurations

  •  Caching

    •  
  •  Models

    • Set   var $recursive in each Model to -1. You can override this in a controller, action or single query as needed.
      Each unnecessary query adds 2-30 milliseconds to the page load time. As your application grows this will get very 'expensive'.
      • When using CakePHP 1.2, use Containable Behavior, that will do unbind/bindModel only your needed associations.

 

General HTML Principles

  •  Keep it W3C compliant.

    HTML that is W3C compliant is parsed easily by web browsers because they aren\47t busy correcting small formatting issues.
    • Cake by default is XHTML Transitional compliant. 
    • Strict is achievable but will mean regulating links for \47target\47 attributes and other minor discrepancies.
    • http://validator.w3.org/ will check your pages(non-recursively)
  • Keep it small

    Just because many people hav high-speed access, doesn't mean your pages should be overloaded with graphics and flash.
    • Set a KB cap and stick to it.
    • Let no single trivial image (icons, buttons, etc.) be larger than 20kb.

 

Cake 1.2 Configurations 

版本: 
關於本網頁的最新 3 訊息 (總計 14 則) - 檢視所有討論主題
2008年6月25日,作者:Smelly_Eddie
Click on http://groups.google.com/group/cake-php/web/optimizing-cakes-performance
- or copy & paste it into your browser's address bar if that doesn't
work.
2008年6月23日,作者:Daniel.S
Or, you could use the now built-in (1.2) Containable behaviour. I used
to use a lot of unbindModel calls, but on a recent project started
using Containable and it's much cleaner and easier.
2008年6月11日,作者:RichardAtHome
The biggest performance improvement I've found so far is:

Unbind unused models! Simple, but very effective.

For example, a few pages in a project I'm working on needed deep
recursion (recursive = 3), which resulted in 4000+ queries O.o

The pages were timing out.

A few unbinds later and its down to 40+ queries.
還有 11 則訊息 »
建立群組 - Google 網上論壇 - Google 首頁 - 服務條款 - 隱私權政策
©2009 Google