ether / nginx-cache
Smart static caching with Nginx
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 5
Type:craft-plugin
Requires
- craftcms/cms: ^3.1.0
This package is auto-updated.
Last update: 2024-10-27 00:54:46 UTC
README
Nginx Cache
Harness the power of Nginx to statically cache your Craft site.
TTFB below 5ms!
Usage
Site Config
Update your sites Nginx conf file to include the three includes below (they are located in your site's storage directory):
include /path/to/site/storage/nginx/cache.conf;
server {
# ...
include /path/to/site/storage/nginx/cache-server.conf;
# ...
location ~ \.php$ {
# ...
include /path/to/site/storage/nginx/cache-location.conf;
# ...
}
}
Reload Command
The reload command will be executed using exec
after the config is saved. If
you find that the command isn't working (Nginx isn't reloading after save) it
is likely due to PHP not having permission to run the command. You can give PHP
permission by adding the command to your server's sudoers
file. To edit your
sudoers
file run $ sudo visudo
on your server, then add the following:
www-data ALL=(ALL:ALL) NOPASSWD:nginx -s reload
Substitute nginx -s reload
with whatever your command is.
If you don't have a sudoers
file you will need to manually reload Nginx after
each save of the plugin config.
Docker
If you are using Docker ensure that your chosen cache directory and Craft's storage directory (or at least the Nginx directory in storage) are available to both your PHP and Nginx containers.