-
Notifications
You must be signed in to change notification settings - Fork 11
Home
The statcache extra is made up of a Plugin for MODX Revolution that writes out static representations of fully cacheable MODX Resources to a configurable location on the filesystem. You can then use your web server's rewrite engine (or equivalent) to serve the static files first, if they exist. This has the advantage of bypassing MODX (and PHP) entirely, allowing you to serve potentially thousands of more requests per second. It has the disadvantage of not allowing any dynamic content to be served however.
See [StaticCache Plugin](StaticCache Plugin) for details on Plugin Events and Properties.
Once the extra is installed and the StaticCache plugin is enabled and generating your static files, you can configure nginx to serve those files first by preceding the standard MODX rules for nginx:
location / {
try_files /statcache${uri}~index.html /statcache${uri} ${uri} ${uri}/ @modx-rewrite;
}
location @modx-rewrite {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
This instructs nginx to look for a static representation of the requested resource within the statcache/
directory inside your document root before all the standard MODX checks. The initial version with the ~index.html
check is there to handle MODX-generated URI's that end with a trailing /
. These are written by the plugin as ~index.html
files so they can be served properly by the web server.