Reflections: Tech

Saturday, June 21, 2008

Tip of the day?

I was hearing a Tech podcast - WebDevRadio - the second episode (the episode was from 2 years ago); the episode is about Web Optimization. Here are some of the presented tips:

  • Send back less HTML to the client! Strip whitespaces, extra carriage returns, and HTML comments - they do not help the user viewing the page. If you have a dynamic site, you can use functions to do these automatically. So you do not need to change page by page.
    In PHP you can use output buffer, store the output, in the end run a function that would do all the above clean up and then gives it out.
    This reduces bandwidth usage. This could help high traffic sites quite a bit.
  • Have external links to JS files rather than inlining it in the HTML page; this reduced bandwidth usage. The linked file gets cached by the client browser, and gets used on successive requests.
  • Compress your Javascript. There are code projects and functions that do this.
  • Using Gzip compression for output data - the client sends the data that "I can accept Gzip compression", the server can now send the gzipped data. The bandwidth usage reduces BUT at the cost of CPU time ... this becomes somewhat of a judgement call.
  • Cookies: Use as few as possible. Possibly just 1. If you had 5 cookies, every request to the server would be pushing the 5 cookies back to the server. Say each cookie was 2K, then every request would be sending an additional of 10K of data.
  • CSS: Using CSS effectively (e.g. classes) rather than HTML for formatting (think about repeated use of " ... ") could reduce the page size of HTML pages.

0 Comments:

Post a Comment



<< Home