There are a bunch of pretty easy things you can do to optimize your website for speed, improving the user experience and scalability of your website - without even touching your code!
This is Ketil's checklist of easy optimizations that will probably give your site a healthy speed boost:
- Don't let MySQL do a DNS lookup for
every single connectfrom the webserver to the SQL server. Avoid this by adding the following option to the [mysqld] section of my.cnf:
skip-name-resolveMake sure to always use IP-addresses in the GRANT command if you do this.
- Compiling the php script before execution can take hundreds of milliseconds - for every hit to your webserver. Install and enable PHP APC on your webserver to cache the compiled code, avoiding compilation delays for every access. You don't need to write any code to use this, even though APC can be used for other sorts of caching as well
- Let browsers cache static files for up to a month. Install and enable the
expires module on your webserver, and add a config something
like this to your virtualhost config to let browser cache images for up to 1 month:
ExpiresActive On ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/png "access plus 1 month"
For further improvements, some more advanced, please check back for the next posting on this subject.
posted at: 15:16 | path: /2010/04 | permanent link to this entry