NANOWEB, the aEGiS PHP web server


The HTTP/1.1 specifies some methods to deliver different variants of files based upon headers the client identifies its or its users preferences / capabilities. This is called content-negotiation and can be accomplished even if the files on the server are "static".

This module now supports server-driven negotiation, and additonially allows the client to choose the "best" variant.
The selection depends on an average »quality« which is calculated with the qualitiy values of the mime type (file format), language (english, french, ...), encoding (compression) and features (javascript, tables, etc.) of each file.

To enable the content negotiation features of nanoweb you only need to construct different variants of a file and give them suitable file name extensions. For example:
example.en.html original HTML version of the document, in english
example.js.html.gz compressed HTML file (using javascript)
example.pdf a pdf version of the original file
example.fr.swf shockwave flash variant, in french

As all the variants of the document now have very different file extensions you cannot refer to them any longer using <A HREF="example.html">, you must instead use just the basename of the file, so nanoweb and/or the client select the right one for you (it is still possible to reference one of the variants, but you probably don't want to do that).
In the above example most people would receive 'example.en.html'; many recent browsers however will trigger the compressed variant (with javascript), and the other two are rather bad examples here.

The alogorith in mod_multiviews of course differs from the one in apache, but it seems to give good results; and you still could tweak it yourself (the source is most always available).
This module for example tries to multiply the different quality factors where possible, but if you specify more than one file type (mime) the according values are summed. Much of the algorithm depends on internal downgrading quality factors, but there are additionally some configuration options which also have a big impact on the results:

FallBackPriority directive

Syntax: FallBackPriority = smallest | largest | newest | oldest | stupid
Context: Server Config, Virtual Hosts, .nwaccess

If the mime qualities of all available file variants equal, then mod_multiviews can at least select the smallest, largest, newest or the oldest file out of them.

LanguagePriority directive

Syntax: LanguagePriority = en fr de
Context: Server Config, Virtual Hosts, .nwaccess

A browser requesting http://example.com/ will be delivered 'index.html.en' in favour of 'index.html.de' (if the users browser has not been configured to request with another language preference)

Of course this only works if no 'index.html' exists in the docroot, which nanoweb otherwise would have preselected. A file called 'index.html.fr.gz' may get send in favour of all other variants, because of the higher priority of compressed content.

MultiViews directive

Syntax: MultiViews = 1
Context: Server Config, Virtual Hosts, .nwaccess

This directive enables / disables mod_multiviews, so you can use the negotiation features only in directories you actually need them.

OtherPriority directive

Syntax: OtherPriority = php; qs=0.28, text/html; qs=0.27, text/*
Context: Server Config, Virtual Hosts, .nwaccess

Is a new directive which sets priorities which come into use, when the client doesn't send an Accept: header As you can see, you may intermix file extensions (as "php" - without dot!) and mime-types known to nanoweb;
where you don't specify a priority value with qs= (0.0 - 1.0) a lesser (divided by 1.7) value as the previous one will be chosen.

Some micro-priorities (PNGs in favour of GIFs) are built-in but can be overridden this way.

Multiple OtherPriority-lines may be given in the config.

ReflectRewriting directive

Syntax: ReflectRewriting = 1
Context: Server Config, Virtual Hosts, .nwaccess

If this directive isn't set, the requested URI will show up in any error message that may occur, if set to 1 the rewritten filename will be shown instead.
Note: This directive also affects mod_rewrite.

NANOWEB, the aEGiS PHP web server