I have NGINX SSI working fine in the virtualHosts file (code below) but LAST_MODIFIED
is returning "(none)", although the NGINX docs for SSI state that the ssi_last_modified
directive appeared in version 1.5.1 (we’re running version 1.14.2).
VirtualHost file:
…
location / {
ssi on;
ssi_last_modified on;
…
}
…
and in the .html file:
<!--#if expr="$footer_id='blackfooter'" --><div id="blackfooter"><!--#else --><div id="footer"><!--#endif -->
<!--#config timefmt="%A %d %B %Y" --><p>Updated: <!--#echo var="LAST_MODIFIED" --> | Today: <!--#echo var="DATE_LOCAL" --></p>
</div>
So for now, I've resorted to JavaScript:
<!--#if expr="$footer_id='blackfooter'" --><footer id="blackfooter"><!--#else --><footer><!--#endif -->
<!--#config timefmt="%A %d %B %Y" --><p>Updated: <span id="updated"></span> | Today: <!--#echo var="DATE_LOCAL" --></p>
</footer>
<script>
let lastmod = new Date(document.lastModified);
updated.innerHTML = lastmod.toString().substring(4,15);
</script>
Why is NGINX delivering other documented SSI functionality, but not LAST_MODIFIED
in the header?
The only possible clue I found was that the sub_filter_last_modified
is mentioned in the docs for the NGINX ngx_http_sub_module but AFAIK (and I'm not NGINX specialist) I'm not sure that helps much.
Because nginx haven't fully implement SSI anyway. Quoting the docs:
For a list of supported SSI commands and variables, check nginx's source here.
Edit:
If complete SSI support is desired, try using Apache httpd behind nginx.
Here's direct quote from
ssi_last_modified
docs circa July 21st, 2021:By default, when responding to a request for a static file, nginx adds
Last-Modified
HTTP response header.When using SSI, nginx remove this header on purpose because nginx is generating the page dynamically instead of returning a static file, therefore adding a
Last-Modified
response header is pointless.ssi_last_modified
directive re-addsLast-Modified
HTTP response header according to SSI script file timestamp.In no way it said that this directive adds
LAST_MODIFIED
variable to nginx's SSI.AFAIK, there's no standard, nor RFCs, that could be relied upon to completely implement SSI. Arguably, docs to mod_include could be such standard, but again, it's only a manual to another product. Let me know if there's such standard and I'll amend this answer.
You'll have better chance resolving this problem by submitting a feature request to nginx's Trac.
Tangent: even if it's supported, if you add
LAST_MODIFIED
, should its value be the timestamp of the SSI script, or server timestamp; since the HTML response is generated on-the-fly instead of directly read from a file.I doubt those large sites still use SSI behind the scenes. At this point, SSI is a legacy framework with a lot of alternatives available.