nystudio107 / nginx-craft

An Nginx virtual host configuration for Craft CMS that implements a number of best-practices.
MIT License
310 stars 37 forks source link

SSI on but critical cookie if/else not resolved #38

Closed davidhellmann closed 2 years ago

davidhellmann commented 2 years ago

Question

Hey Andrew, I implemented the criticalcss etc. like you:

{# -- Critical CSS -- #}
{#
# Use Nginx Server Sider Includes (SSI) to render different HTML depending on
# the value in the `critical-css` cookie. ref: http://nginx.org/en/docs/http/ngx_http_ssi_module.html
#}
{% set cssHash = craft.vite.getCssHash("src/js/app.ts") %}
{#
# If the `critical-css` cookie is set, the client already has the CSS file download,
# so don't include the critical CSS, and load the full stylesheet(s) synchronously
#}
<!-- # if expr="$HTTP_COOKIE=/critical\-css\={{ cssHash }}/" -->
{{ craft.vite.script("src/js/app.ts", false) }}
<!-- # else -->
{#
# If the cookie is not set, set the cookie, then include the critical CSS for this page,
# and load the full stylesheet(s) asychronously
#}
<script>
  Cookie.set("critical-css", "{{ cssHash }}", {expires: "7D", secure: true});
</script>
{{ craft.vite.includeCriticalCssTags(criticalPath) }}
{{ craft.vite.script("src/js/app.ts", true) }}
<!-- # endif -->

I also have ssi on; on my forge nginx config. But my HTML looks all the time like this: image

It's live here: https://stage.baukasten.io

Is there something what I miss on config side? 🤔 Looked at on devmode.fm and there are no SSI snippets to see. What means it works on your site :D

khalwat commented 2 years ago

I'd have to conclude that ssi is not actually enabled/working then?