Delivers static files. More...
#include <staticfilecontroller.h>
Classes | |
struct | CacheEntry |
Public Member Functions | |
StaticFileController (QSettings *settings, QObject *parent=0) | |
Constructor. | |
void | service (HttpRequest &request, HttpResponse &response) |
Generates the response. |
Delivers static files.
It is usually called by the applications main request handler when the caller request a path that is mapped to static files.
The following settings are required in the config file:
path=docroot encoding=UTF-8 maxAge=60000 cacheTime=60000 cacheSize=1000000 maxCachedFileSize=65536
The path is relative to the directory of the config file. In case of windows, if the settings are in the registry, the path is relative to the current working directory.
The encoding is sent to the web browser in case of text and html files.
The cache improves performance of small files when loaded from a network drive. Large files are not cached. Files are cached as long as possible, when cacheTime=0. The maxAge value (in msec!) controls the remote browsers cache.
Do not instantiate this class in each request, because this would make the file cache useless. Better create one instance during start-up and call it when the application received a related HTTP request.
Definition at line 41 of file staticfilecontroller.h.