Processors for sites
Processors in a site are the heart of a site configuration, responsible for handling different types of content and requests. Often, multiple processors are required to achieve the desired behavior, because a site is commonly composed of several layers.
Processors are executed in the order they are defined in the site configuration. This allows for flexible and powerful request handling, as you can chain multiple processors together to achieve the desired behavior.
Common processors include static file serving, PHP processing, and reverse proxying.
Only one processor can handle a request
You can define as many processors as you want on a site, but only one processor will handle each request. Processors are evaluated in priority order, and the first processor that matches and chooses to handle the request will handle it. The remaining processors are skipped.
Processors can also be used for reverse proxying, where requests are forwarded to another server or service.
Processors can be customized with URL matching rules, allowing you to define which requests should be handled by each processor. This provides granular control over request handling and enables complex site configurations.
URL matching rules
URL matching rules allow you to specify which URLs should be handled by each processor. These rules can be based on URL prefixes, patterns, or other criteria, enabling precise control over request routing within a site.
Rule types include exact match (for example, /mypath/script.js), starts-with (for example, /mysite/*), and ends-with (for example, *.js).
The final simple type is the wildcard *, which matches all requests.
No processors match?
In the case where no processor matches a request, the server will return a 404 Not Found response, indicating that the requested resource could not be found.
PHP site example, like WordPress
- Static file processor (priority 1) - The static file processor checks if the requested file exists on the filesystem. If it does, it serves the file directly to the client, which is orders of magnitude faster than invoking the PHP processor.
- PHP processor (priority 2) - If the file does not exist, the request is passed to the PHP processor, which executes the PHP script and generates the appropriate response.
Reverse proxy example
- Proxy processor (priority 1) - URL matching
/api- If the request starts with/api, it is forwarded to the proxy server (for example, a backend API service). - Proxy processor (priority 2) - URL matching
/app- If the request starts with/app, it is sent to a backend server handling application logic. - Static file processor (priority 3) - If neither proxy processor handles the request, the static file processor checks if the requested file exists on the filesystem. If it does, it serves the file directly to the client.