optimizing my velocity scripts

bchiu's Avatar

bchiu

24 Sep, 2012 08:25 PM

I have a script that generates a side nav from the pages within the current directory.
During low traffic, a page containing this script will publish under 2mins.

2mins each page multiplied by 50 pages or so equals timeout during day time.
To make this work, I had to publish these pages at night time.

Below is the live site where this script is implemented
http://www.qcc.cuny.edu/employment/index.html

The attached script contains one FOR EACH loop populating 10 separate arrays, two for each category.
Then I would have 5 FOR EACH loops to extract the data in to each category to be displayed.

My previous version of this script had a nested loop that did all the work. But that script would time out and throw timeout errors for each server it publishes to.

Currently the CMS server is set to publish to multiple servers.

I was wondering if I am able to optimize my script to minimize the publishing time. Any help would be greatly appreciated.

  1. 1 Posted by Ryan Griffith on 25 Sep, 2012 12:32 PM

    Ryan Griffith's Avatar

    Hi,

    Would you be able to provide the XML contents of your Index Block as well for testing?

    Thanks!

  2. 2 Posted by bchiu on 25 Sep, 2012 01:27 PM

    bchiu's Avatar

    Good Morning Ryan,

    Thank you for your prompt response.

    I have attached the index block as txt.

  3. 3 Posted by Ryan Griffith on 25 Sep, 2012 04:00 PM

    Ryan Griffith's Avatar

    Hi,

    I hope you don't mind, but I re-tooled your Velocity a bit, see attached. Here is a breakdown of what I did:

    • Utilized common macros for displaying the repetitive content (ie each category heading and container and each listing under the category). This helps cut down on the length of the Format and makes things a bit more manageable.
    • Because the Categories were hard-coded anyway, I used XPath to query an existing variable for listings within each category, rather than looping through and saving to multiple arrays and then looping through each array. This helps cut down on the overall complexity and also makes it a bit more manageable.

    Note: Because this uses macros, if you are on a version of Cascade prior to 7.0.3 there may be issues with the macros caching. So if you update the macro and your updates don't seem to take, rename the macro each time and that should clear the cached macro.

    Please let me know if you have any questions.

    Thanks

  4. 4 Posted by dmoretti on 25 Sep, 2012 05:10 PM

    dmoretti's Avatar

    Thank you Ryan, I appreciate the help. We are running Cascade 7.0.3 (64-bit version).
    Dave
    ________________________________________
    From: Ryan Griffith [[email blocked]]
    Sent: Tuesday, September 25, 2012 12:00 PM
    To: Moretti, David
    Subject: Re: optimizing my velocity scripts [Velocity Formats #256]

  5. 5 Posted by Ryan Griffith on 25 Sep, 2012 05:50 PM

    Ryan Griffith's Avatar

    Not a problem at all. You shouldn't have to worry about the macro caching with your current version, so that's good news.

    I'm going to go ahead and close this discussion, but feel free to reply or comment to re-open this discussion if you have any additional questions.

    Thanks.

  6. Ryan Griffith closed this discussion on 25 Sep, 2012 05:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac