Open Ask AI (⌘/Ctrl+I)

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

  1. Go to your country filter.

    This is typically found at /modules/personalization-traits/traits/country.

  2. Change the traitStorageClass to $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
  1. 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