Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Server side includes

Server side includes (SSI) are directives in HTML pages that get evaluated on the server while the pages are being rendered. Use of server side includes enables you to add dynamically generated content to an existing HTML page without having to serve the entire page.

More information about nginx SSI.

You can activate or deactivate SSI on a per-route basis in your .magento/routes.yaml; for example:

1
2
3
4
5
6
7
8
9
10
11
12
    "http://{default}/":
        type: upstream
        upstream: "myapp:php"
        cache:
            enabled: false
            ssi:
                enabled: true
    "http://{default}/time.php":
        type: upstream
        upstream: "myapp:php"
        cache:
            enabled: true

SSI enables you to include in your HTML response directives that cause the server fill in parts of the HTML, respecting the your caching configuration.

The following example shows how to insert a dynamic date control at the top of a page and another date control at the bottom that updates every 600 seconds:

Add the following to any page, such as /index.php:

1
2
echo date(DATE_RFC2822);
<!--#include virtual="time.php" -->

Add the following to time.php:

1
2
header("Cache-Control: max-age=600");
echo date(DATE_RFC2822);

Browse to the page on which you added the control. Refresh the page several times and notice that the time at the top of the page changes but the time on the bottom changes only every 600 seconds.

Updated