There are different options below. Many of them can be combined together:
- Enable nginx reverse proxy.
- Configure nginx caching for website (Plesk Onyx 17.8 and Plesk Obsidian only)
- Enable gzip compression for nginx or for Apache.
- Use Speed Kit extension.
- Use PHP 7 with opcache.
- Enable nginx reverse proxy:
Install the nginx reverse proxy component:
- Log in to Plesk.
- Go to Tools & Settings and click Updates and Upgrades.
3. On the Updates and Upgrades page, click Add/Remove Components.
4. On the Add/Remove Components page, expand Web hosting and select Nginx web server for installation. Click Continue to begin the installation.
5. Once the component is installed, enable the nginx reverse proxy service in Plesk:
i. Go to Tools & Settings > Services Management.
ii. Click the Start button next to Reverse Proxy Server (nginx) once and wait. The process will take some time to configure.
To enable nginx Byte-Cache and nginx FastCGI caching, follow these steps:
Enable nginx caching for single domain
- Login into Plesk
- Go to Domains > example.com > Apache & nginx Settings
- Tick the Enable nginx caching option and press the OK button to apply the changes:
Enable nginx caching for all domains using a service plan
- Login to Plesk
- Go to Service Plans > Hosting Plans tab
- Click on the name of the existing plan to edit it.
- Go to the Web Server > nginx settings and enable checkbox next to Enable nginx caching:
5. Click Update & Sync
Enable GZIP compression for nginx or for Apache
- For a Domain In Plesk – Enabling gzip compression for a domain in Plesk
- Log in to Plesk.
- Go to Domains > example.com > Apache & nginx Settings.
- Add the following directives to the Additional nginx directives field:
gzip on;
gzip_disable “MSIE [1-6]\\.(?!.*SV1)”;
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/rss+xml text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;
Note: This is an example. If needed, add other file types in thegzip_types
section, e.g.application/javascript
,application/js
, etc. The full list of available types can be found on a server in the file/etc/nginx/mime.types
. - Apply the changes.
- For all domains via nginx global configuration – Enabling gzip compression server-wide
- Connect to a Plesk server via SSH.
- Create the
gzip.conf
file inside nginx conf.d directory:
# touch /etc/nginx/conf.d/gzip.conf - Open the file in any text editor. In this example, we are using the vi editor:
# vi /etc/nginx/conf.d/gzip.conf - Insert the following content in it:
gzip on;
gzip_disable “MSIE [1-6]\\.(?!.*SV1)”;
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/rss+xml text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;
Note: This is an example. If needed, add other file types in thegzip_types
section, e.g.application/javascript
,application/js
, etc. The full list of available types can be found on a server in the file/etc/nginx/mime.types
. - Save the changes and close the file.
- Test nginx configuration:
# nginx -t - Reload
nginx
configuration to apply the changes:
# service nginx reload - Now gzip compression is enabled for all domains on the server.
To verify that gzip compression is enabled, use the command below. When gzip is enabled you will see ‘Content-Encoding: gzip’ in the output:
Note: If the website has a www redirection, change the website name to www.example.com.
* If the website is using HTTP connection:
# curl -s -H “Accept-Encoding: gzip” -I http://example.com | grep -i Content-Encoding
Content-Encoding: gzip
* If the website is using HTTPS connection:
# curl -s -H “Accept-Encoding: gzip” -I https://example.com –insecure | grep -i Content-Encoding
Content-Encoding: gzip
- How to enable gzip compression in Apache on Plesk server?
- Log into Plesk
- Make sure that ‘deflate’ and ‘filter’ modules (‘filter’ might be absent on CentOS 6) are enabled in Tools & Settings > Apache Web Server.
3. Go to Domains > example.com > File Manager and open the .htaccess
file.
4. Add the following content to the bottom of the file:
- Use Speed Kit Extension
- Use PHP 7 with opcache
How to ensure that Opcache is enabled?
1. Check which PHP handler is used by the website at Domains > example.com > PHP Settings > PHP support ( PHP version …)
Note: According to PHP Documentation, OPcache is available only since PHP 5.5. For PHP 5.2, 5.3 and 5.4 it can be installed as PECL extension.
2. Check if Opcache is enabled for the domain at Domains > example.com > PHP Settings > Performance Settings > opcache.enable “on”
3. Check if Opcache is enabled for the handler at Tools & Settings > PHP Settings > handler name
Note: Opcache statistics is available at Domains > example.com > PHP Settings > View the php_info() page – cache hits, cache misses.