Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Recent pages and files
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 

Version: 
Latest 3 messages about this page (14 total) - view full discussion
Jun 25 2008 by 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.
Jun 23 2008 by 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.
Jun 11 2008 by 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 more messages »
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google