Cache backend responses
By default, Magnolia sets the Set-Cookie header when the country filter (personalization) and CSRF security are enabled. Because of this, responses from backend servers aren’t able to be cached. However, there are some things you can do to make these backend responses cacheable.
Workaround instructions
-
Go to your
countryfilter.This is typically found at
/modules/personalization-traits/traits/country. -
Change the
traitStorageClassto$RequestScopedTraitStorage. Alternatively, you could completely disable the country filter.
What you want
info.magnolia.personalization.trait.storage.StorageAwareTraitCollector$RequestScopedTraitStorage
What you don’t want
info.magnolia.personalization.trait.storage.StorageAwareTraitCollector$SessionScopedTraitStorage
- Next, you’ll need to bypass the CSRF filter with paths/content-types (and whatever else you need) in the filter configuration. This is done with a voter.
Example voter
BypassWhenNotAuthenticated:
class: info.magnolia.voting.voters.AuthenticatedVoter
not: true