Tips of how to optimize drupal's performance
时间:2010-07-19 来源:haohappy2
Tips
Drupal is one incredible technology which is getting better and better with each passing day. A number of websites are relying on the power of Drupal and benefitting from the immense utility that Drupal brings to the fore. However, no technology is fool-proof and even the much talked about and popular Drupal has had its share of problems. Many a time users have complained regarding slow page loads which deter them from accepting Drupal as a revolutionary technology.
Every Problem warrants a Solution and with this article coupled with my experience on Drupal optimization I would like to clear the air regarding problems faced using Drupal and would like to share some tips with all you Developers/Drupal Enthusiasts reading my article right now:
1. GZIP - In Drupal, pages are written to the cache in GZIP form. You need to configure your Apache server to automatically compress GZIP format files.
- E.g. Add the following line: AddOutputFilterByType DEFLATE text/css application/x-javascript to your .htaccess or httpd.conf files
2. JS files at the Bottom
As a Standard Practice all the browsers load everything in the <head> tag first. Since these days JS files are usually of very large sizes it is considered a wise action to place the JS right at the bottom of a page to achieve faster load time.
3. YSLOW
If you’re a developer it becomes that much important for you to equip yourself with a wonderful utility called YSLOW Firebug, which helps in analyzing a webpage and make a diagnosis on why your website is slow. YSLOW also gives out handy solutions to fix the flaws.
4. Scale down HTTP requests
By narrowing down comments and whitespace Drupal demonstrates its CSS compression utility. It is highly recommended to enable CSS and JS aggregation features available in Drupal which can be done by accessing admin/setting/performance inside your Drupal website.
5. Deploy CDN integration
URLs must be written in Drupal to serve the files from a Content Delivery Network (CDN). This CDN integration serves a great purpose and reduces load time especially for users who are far away from your server location.
6. Placing CSS at the Top
To ensure faster page loads, place the stylesheets to the document HEAD.
7. CSS Expressions must be Avoided!!
CSS expressions are calculated every time a user moves the mouse over the page, during page rendering, page scrolling and page resizing and for this very reason it makes good sense to avoid CSS expressions.
8. JS and CSS should be made external as far as possible
For faster page loads inline JS and CSS should be judiciously used.
9. Minimize DNS lookups
Widgets have become an integral element of many websites. Drupal allows the option of running as many widgets on your website as you may want. However, I would recommend all these widgets to be stored on your website or to your CDN. E.g. è install the Google Analytics Module while using Google analytics as it carries a feature to cache the .js files locally and updates it on a daily basis.
10. Avoid Redirects
As a practice avoid redirects as far as possible to ensure an optimal performance and great user experience working with Drupal.
11. ETags
ETags are used to accurately pin-point a file and investigate whether the file on the browser cache is matching with the file on the server. These are generated using inodes from the server they are being served. This is where the problem lies and it becomes s omuch important to disable ETags while using multiple servers to save on load time. To do this, Apache users can add the following line:
FileETag none
to your httpd:conf
or alternatively you can use a single server to serve files or use CDN (if possible).
That seems it. Try implementing the above suggestions and check out the difference. Drupal is designed to give an exciting experience to its users and should not be disregarded just because of some hiccups which every new technology goes through. For Problems there are Always Solutions. Explore them. Happy Drupal ing Guys !!!