Partition Web Site
Partition a web site by rewriting the links
This would be the fastest and most transparent way as far as the clients and host are concerned but it does mean that the site must be copied in its entirety to another folder on the development server before being uploaded because the links would become unuseable as static links.
Partition using client side scripts
The title is a little misleading of course. The partitioning would be done on the development host but would not involve any rewriting of the files. What would have to be written is a script file that provided the means to load the appropriate page. This means that we would not need to create complete copies of the site and we could simply upload the files that have changed and those that are newly created. In addition we would have to upload the latest version of the script.
Partition by creating redirects in .htaccess
This is probably the best thing to do because the site need not change at all. All the links can be static and the redirection takes place on the server. The problem is that this only works on Apache and compatible servers and even then only if the host allows you to write .htaccess.
Replace some files with redirects.
In this version we replace files with others that contain only the redirection. Many of the files that are referred to by the replaced file can be moved to the host referred to by the redirection.
Which to choose
I thought that the choice was plain. Rewriting the links would be a massive amount of run time and also a significant parsing problem. Htaccess is probably not allowed everywhere so that is out. That leaves ECMAscript and redirects.
There are lots of ways to implement the ECMAScript version. The simplest is probably to leave the links as they are except that they would be wrapped in a call to a function. The function would check for the existence of the page at the current server. If it exists then it would load it. If not it would try the other servers in turn until it finds it. In this way the only thing to be done is to copy as much as will fit to one server, then the next and so on. Leave enough space on each server for a small script that names all the servers.
Nonetheless the simplest to implement is probably redirects. A simple application can be written that copies the site to a set of upload directories while tracking the space used. Once the allocated space has been used the application simply continues by writing other files to corresponding locations in the next upload directory. Once this is complete we must parse all the files in all the upload directories looking for links. If the linked to file is present in the same upload directory tree as the linked from file then do nothing; if it is not then check the other directories for it and write a redirection file in the place where it was expected to be.
Another method would be to create a local copy of the web site directory structure in each of the upload directories create a place holder file for each of the real files that redirects to the next site. Now run the process that copies the actual files to the upload directories as before. This will overwrite the redirection files until it runs out of space and then move on to the next upload directory. Doing it this way avoids the complication of parsing the files to discover which file needs a redirection file. It is better than client side scripts because it leaves us free to create links as anchors or script links as we like and as appropriate without considering how the site fills up.
Of course the ECMAScript way of doing it could be simplified by using the experience gained in AutoMenu. That is run a script in the body onload event that modifes all the anchors it can find to run a script instead. The advantage of this method is that adding a new server does not require massive changes to the existing ones only a change to a single script file to name the new server.
No comments:
Post a Comment