Nginx configuration to serve cache without PHP

FlyingPress will work out of the box with any web server. But in Nginx, cached files will be served via PHP.

This can slightly degrade the performance if there are low server resources or a lot of traffic.

By configuring Nginx to server cache, no requests will hit PHP!

Inside your Nginx configuration directory (usually  /etc/nginx/), create a new file named flying-press.conf with the following contents:

Now include that file inside the server block of your main Nginx config:

server {
  # Flying Press configuration
  include flying-press.conf;

Before you reload your configuration, make sure you test it:  nginx -t

Once your test is done, you must reload your configuration.  service nginx reload

You’ll also see a response header  x-flying-press-source: Nginx indicating that it’s served via Nginx. Otherwise, it will be PHP.