24.2 Optimizing Updates

Consider the following situation: file structure.cws defines some arrays storing informations about site structure:

structure.cws

topics = { "vegetarianism", "vivisection", "hunt" };
vegetarianism_subtopics = { "animal_suffering", "health", "world_hunger" };
vivisection_subtopics = { "useless", "ethically_wrong", "dangerous" };

Now, every page includes this file and use these informations to display a navigation bar. Since every page depends upon structure.cws, if you change it, Make will update the whole site. This is not a good thing for very large sites so you may consider a different approach and split structure informations among various files:

structure.cws

topics = { "vegetarianism", "vivisection", "hunt" };

veg_struc.cws

vegetarianism_subtopics = { "animal_suffering", "health", "world_hunger" };

viv_struct.cws

vivisection_subtopics = { "useless", "ethically_wrong", "dangerous" };

Now, each page will include topics.cws and only one of the files storing informations above subtopic. As an example, a page belonging to section vegetarianism will begin with:

include ("topics.cws");
include ("veg_struct.cws");

while a page belonging to vivisection will begin with:

include ("topics.cws");
include ("viv_struct.cws");

Now, if you change a topic all pages will be updated but if you change a subtopic of, let's say, vegetarianism, only pages belonging to its section will be updated.

This is a general rule: the more you split files and include them selectively in your pages, the better update procedure you'll get. Of course, for each project you have to ask yourself if the effort needed is worth the benefit obtained.

Also consider that there are situations where it's impossible to achieve this separation. As an example, you may want a navigation bar displaying all the topics and all subtopics in each page. So each page must know about the whole structure. Of course, including all files veg_struct, viv_struct etc. in every file is equivalent to including a single file with all these informations. Splitting files makes sense only if you include them selectively.

This manual can be downloaded from http://www.g-cows.org/.