I’m attempting to get {{httpInclude ...}} working, but rather than including the contents of the URL in question, it’s outputting the literal string - I’m not sure what I’m not doing correctly.
Blitz is a caching utility for CraftCMS. It takes server responses from PHP and writes them to disk as a static file; then we’re using Caddy to serve those static files if they exist, as long as there isn’t a query string in the URL.
Blitz also supports SSI for nGinx and Apache.
I’m trying to get it to support “Caddy SSI”, which seemed like it shouldn’t need anything more than altering the SSI syntax from
I’m not seeing the templates directive in your Caddyfile config. You need to enable the templates handler for that to do anything.
Since Caddy templates don’t use HTML-style comment syntax, you’ll need to make sure that all user-generated content is filtered, to make sure other content doesn’t get parsed as templates. You should only use templates if you’re sure that all content produced by your upstream app is safe to parse as a template.
I knew there would be something stupid I was missing, working too late! Thanks!
For the sake of completeness if anyone else stumbles onto this, and because the docs don’t have examples of things in context, here’s a working Caddyfile that also supports “SSI”:
This also changes the “start of a template instruction” and “end of a template instruction” from the default {{ and }} delimiter strings.
In the context of a Craft project those defaults may be problematic because they are valid Twig start and end delimiters. In debugging scenarios it’s possible that the end rendered HTML would contain those delimiters, causing an issue here.
I have therefor changed them to delimiters that are sure to not be present in any HTML:
<!--#caddy to mark the opening delimiter
--> to mark the matching end delimiter
This means that a complete string output in an HTML file that would trigger an “SSI” might be: <!--#caddy httpInclude "/path/to/cached-output" -->