thanks to Yii, main modules of my site are done. now it looks like a real website.
but unfortunately it starts up very slow (taking about 2-3 seconds to load the frontpage), and the response to subsequent requests are also slow (also 2-3 seconds).
i was wondering if experienced yii developer can enlighten me how to make it run faster.
perhaps i need to use memcache or some caching software?
perhaps i need to use a kind of benchmark software to see what codes are slowing me down?
what principles in development should i follow to get a final quick site? (e.g unset used $model and $dataProviders?)
Enable APC cache for opcode caching and data caching (it is faster than memcached if you are using a single machine - that’s at least my experience).
Try using DAO for READING tons of models when you have to display them in a view for example. ActiveRecord is better suited for create/update operations than reading operations with large resultsets
Use fragment caching to cache parts of your site that are loaded frequently but hardly change
Some additional stuff can be the use of CCacheHttpSession and minimizing script files like explained in
thank you, Haensel and Mdomba, i will check the items you suggested one by one.
but by the way, is it a good practice to use different view files for the different logic branches in a same action, than to implement the logic branches in the same view file? the balance is that, 2 view files result in additional file IO but 1 view file would be a twisted and bunting view file.
for example, is it good to write 2 different view files for authenticated users and guest users and render them accordingly in the controller?
they say php is a stateless language,that is, for every new request, php would have to load required components, parse the scripts, connect the database etc all over again. thus php is actually slower than other language, e.g Java.
i don’t know if Yii has any special mechanism to overcome some of php’s shortcomings.