Click here to register.
      

How to Improve Performance for Navigations

Design Squid
How to Improve Performance for Navigations
preaction · 2/23/2010 11:41 pm

Let's say you have the following scenario:

  • A large, main section of your website available to the public
  • A main navigation on every page
  • A separate, private area of your website not part of the main area.
  • Navigation does not change if a user is logged in or not.

If you have a static navigation, you can use the following procedure to increase performance dramatically:

  1. Create a snippet (called Main Nav Cached)
  2. Add an AssetProxy macro for the main nav to the snippet: AssetProxy(main-nav)
  3. Set the "Process As Template" to "Yes"
  4. On the Display tab, set the Cache Timeout to an appropriate value. The snippet will cache the navigation for this long, which means it may take this long for changes to the navigation to show up. You can clear the cache manually to make new changes appear (Admin Console > Cache tab)
  5. On the Metadata Tab, add any Extra HEAD Tags from the Navigation's template (because the AssetProxy macro cannot add extra HEAD tags)
  6. On your style template, use AssetProxy for your Snippet instead of your Navigation

The first time the snippet is used, it will load the Navigation and then cache the result and use that cached result for every subsequent page request. Once the cache expires, it will load the Navigation one more time, and then again keep using the cached version.

On one of our client sites, we reduced page render times from 3 seconds to 0.5 seconds, a 600% improvement!

If your navigation does not change often at all, you can improve performance even further by replacing the AssetProxy macro in the snippet with the HTML from the output of the Navigation. The downside here is that you will have to manually update the Snippet when the Navigation changes, but it will be extra special fast. You can also use the GroupText macro here to make admin-only menu items.

Re: How to Improve Performance for Navigations·
patspam · 2/24/2010 10:51 am

Genius.

·
Stick
Lock
Subscribe