Question:

How can I optimize my website to download faster?

by  |  earlier

0 LIKES UnLike

I am designing a website and some pages take way too long to load. Especially since I am expecting high traffic rates and I know that my website would slow to a crawl if it was getting a couple hundred hits a day.

I know about using CSS instead of HTML to load images, and I know about making CSS files as small as possible, but that hardly makes it faster.

Also, which is the fastest way to display identical content on several pages? IFRAME, or PHP Include statement?

 Tags:

   Report

2 ANSWERS


  1. Exactly how to optimize your website depends largely on what it's doing, though there are some generally accepted guidelines. If you expect that only a few hundred hits a day will bring your site to its knees, you've got some work ahead of you.

    Keep in mind that a website that contains dynamic content will always be slower than static HTML content. The difference is pretty trivial these days, though for a large, resource intensive application, it can become quickly noticeable.

    That said, unless you're working with obscenely massive CSS files, you won't realize much difference by reducing their size. Also keep in mind that the main benefit to server-side-includes (PHP or otherwise) is reusability, not performance. I typically avoid the IFRAME construct, unless there is a highly compelling reason to use it (displaying external content that is unavailable via any other transport, for example).

    So, what are your options? There are a few:

    1. Choose your hosting provider wisely. This may seem like a no-brainer, but may people skimp here, which can only hurt you. That doesn't mean that you have to pay an arm and a leg for a shared hosting account, but the old adage of "you get what you pay for" still applies. A well designed, reliable hosting infrastructure can make all the difference in the world.

    2. As previously mentioned, optimize images used on the site. Images used on a website should be 72dpi, and -- in most circumstances -- don't need to be maximum quality.

    3. Limit the number of other large, binary resources displayed on each page. If you're loading several large images, Flash movies, etc,. it's going to have a negative impact for users on all but the fastest connections.

    4. Implement caching for infrequently changing dynamic content and/or expensive resources. Say, for example, you have a web page that accesses a web service to display stock information to the user. Accessing an external web service is typically an "expensive" operation in terms of performance. And since most financial feeds are delayed by 15 minutes anyways, it doesn't make sense to query the service every time a user hits the page. Depending on your specific application, you may or may not be able to cache your data, but I have built applications that keep information cached in memory for a month or more.

    5. Limit round trips to the database. Database access (and especially transactional writes) are one of the most expensive operations you can perform. Access your database only when absolutely necessary (see #4 above), Don't reload rows from the database on postback unless they've changed. When possible, spawn a separate worker thread or use AJAX to interact with the database so that the user is less aware of the latency.

    6. Avoid direct file system access in your scripts. File system access is notoriously slow. Avoid interacting with the web server file system whenever you can, and when you can't, use worker threads, message queuing, AJAX, or other tricks to make such operations (appear) as asynchronous as possible.

    Hope this helps, and good luck with your website!

    ||| Kristopher Cargile

    ||| www.bettersoftwarenow.com


  2. Use SSI (Server Side Includes) identical on every page.  Especially if you plan to add/delete the content like nav links.

    Optimize all images to web standards.

    Don't use a lot of animation or sound files.

    More tips:

    http://www.rubyrobot.org/article/5-tips-...

    Ron

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.