verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
95 stars 72 forks source link

Don't start unnecessary sessions for cache-abilty #1752

Closed timkelty closed 7 months ago

timkelty commented 7 months ago

A page with formie on it will always return Set-Cookie headers, even when it isn't neccessary.

This will cause many caching mechanisms (Craft Cloud, Fastly, Varnish) to consider the request uncacheable.

timkelty commented 7 months ago

@engram-design FWIW – craft\helpers\Session methods do similar checks: https://github.com/craftcms/cms/blob/develop/src/helpers/Session.php

engram-design commented 7 months ago

Yeah cool, I might swap out calls to use the helper anyway, makes:

$pageId = Craft::$app->getSession()->getHasSessionId() ? Craft::$app->getSession()->get($this->_getSessionKey('pageId')) : null;

A bit easier to read with:

$pageId = Session::get($this->_getSessionKey('pageId'));
timkelty commented 7 months ago

Yep exactly. I just discovered the helper myself 😆