Skip to main content

Faster Yahoo! Store publish

Recently I did a complete redesign in a store. As part of the redesign, I added a hierarchical, DHTML menu navigation bar to the site. In a typical setup, such a navigation bar works like this: use WITH-OBJECT :index to reference the home page, then cycle through the contents field, create a menu label for each page you find there, and for any such page, create a sub-menu if the page also has contents.

If you didn't know until now, whenever you reference another object in RTML, such as using WITH-OBJECT or FOR-EACH-OBJECT, such a reference causes a disk lookup on the server. This is what we call an "expensive" operator; it is expensive in terms of processing power and time, so a navigation bar in general, and a hierarchical navigation bar in particular is an "expensive" template.

In the store I was working in, they had over 4,000 pages, and of course, each of those pages had the navigation bar on them. So not surprisingly, the time it took to publish this site went from a couple of minutes to 3-4 hours!

ONCE to the rescue

There are many ways to write good, efficient, and bad inefficient RTML code, but regarding of your coding style, there is one operator you should consider every time you write a piece of code that won't change from page to page, and it is the ONCE operator.

Once takes one parameter, which can be either :page or :publish. What it means is that whatever you paste within ONCE will be evaluated only once per page or per publish. Now, per page is not that interesting (I think at least, I haven't really found any use for that,) but per publish is great.

When you use ONCE :publish, the expressions pasted inside it are evaluated only once during publishing. So how can you speed up your navigation bar? The immediate idea is to simply paste your original navigation code inside a ONCE :publish. Ok, try it, and you'll be quite surprised: your navigation bar will appear only on a single page, the first one that was generated during your publish. Not exactly what you want, but if you think about what ONCE does, it does make sense: you asked it to generate your navigation bar once per publish. To get the speed benefits of ONCE :publish and also end up with a navigation bar on every page, do the following small variation:

TEXT ONCE :publish
GRAB
... generate your navigation bar here ...

Now this will do the trick nicely! We still generate the navigation bar once per publish, but now the result is saved (GRABbed) and output on each page!

With this simple trick, my store's publish time went back to about 5-10 minutes.

I use this trick all the time for pieces of the page that doesn't have to change throughout the site. It works nicely for banners, footers, random testimonials, etc. You can use the above code snippet as a boiler plate, just put the code that needs to be evaluated once inside the GRAB operator and you'll be all set. Be careful though, don't do this to code that changes from page to page (for example, you cannot use this trick if your navigation bar changes based on which main category you are in.)

Editor still slow?

Ok, you've tried it, publish time is great, but your editor is slow. Chances are you have some inefficient RTML code in your templates, and if that's the case, ONCE will not save you anything there. Why? Because when you are in the editor, you are essentially publishing each page every time you view a page! Not the entire store (of course), but viewing any page in the editor is a "mini publish" of that page. So if you take my DHTML menu example above, that menu needs to be re-generated in the editor every time you view a page. One way to speed up the editor is to turn off slow pieces of code while in the editor. For example, you can program your template so that it does not show a navigation bar while in the editor (in the editor, you can still navigate in other means, like a bottom of page text navigation, breadcrumbs, or clicking the "Contents" button.) This is, though, a different tip for a different post!

Comments

Popular posts from this blog

Pre-Season Checkup

With the holiday shopping season fast approaching it's a good idea to do a general checkup on your store to be sure it's ready for prime time. Below are a few things you would want to check, along with a few add-ons that are not too major in scope, but which are often neglected and give you an edge over your competition.

Can you Search and Order?
Every time we do anything major in a store we test two things: whether searching and adding to cart/ordering works. You can have nice, flashy pictures, cool animation effects, a very quick loading site, anything, but if the store search is broken or you can't add to the cart or can't check out then an ecommerce site is worth nothing.

Can you Order?
Chances are if your checkout was completely broken you'd know about it by now, but it doesn't have to be totally broken in order to scare away potential customers. So go ahead, go to your site and first do a search and make sure it works. Then, add one or more products to your…

How to create clean and efficient CSS

In a typical workday, I deal with dozens of yahoo stores and very often I have to tweak, fix, or change CSS used by these stores. While some stores have very clean and easy to follow style sheets or CSS definitions, the vast majority of stores I've seen seem to include complete hack jobs, style sheets put together completely haphazardly, or as an afterthought. While working in such a store, the idea came to me to turn my gripes into a post. So the following is my list of dos and don'ts of good CSS or style design.

1. Externalize your style sheets. This means to save your style sheets into one or more css files, and link to them using the <link rel="stylesheet" type="text/css" href="/lib/yourstoreid/yourstyle.css"> notation, or in Editor V3.0, you can use the LINK operator.

2. Combine your style sheets into as few files as possible. Nothing worse than trying to wade through 6, 8, 10 or more different style sheets to find the color of a li…

What is product-url anyway?

I keep having to field questions about the product-url field, and since it came up yesterday, I figured I'd try to clear up all the confusion about it.

So the name product-url suggests that whatever you type in there will become the URL of that product. Unfortunately, this is not the case, or rather, not in the intuitive way. The URL you enter there will be used as the URL for that product in Yahoo Shopping, on the built-in search results page, and on the shopping cart page, however, the URL you type in there DOES NOT actually change the physical URL of the page.
What is the URL of a page in a Yahoo Store? In any Yahoo Store built in the store editor, the URL of a page is the store's domain name and the page ID + .html. For example, in my store at www.ytimes.info, I have a page whose id is rtml101, thehrefore, the URL of that page is http://www.ytimes.info/rtml101.html.
Why would you want to change the URL? For SEO reasons, it is believed to be better to have a URL that includ…