Closed Zae closed 2 years ago
Preview requests can probably be excluded by default from being cached. I guess the same also applies to environments where devMode
is enabled.
But if the default configuration doesn’t work for you, it’s always possible to configure caching behaviour via the config file. We are disabling caching in dev environments, for example.
return [
'defaults' => function() {
$isDev = getenv('ENVIRONMENT') === 'dev';
return [
'cache' => $isDev ? false : 'P1Y', // one year
];
},
'endpoints' => [],
];
Thanks for the PR! Just released Element API 2.8.0 which solves this.
Description
When preview mode is enabled in the request do not try to fetch from or write to the cache, this fixes possibly fetching stale content or writing draft content to the cache.
Note: I'm using
getToken()
instead ofisPreview
, becauseisPreview
returns false when using theX-Craft-Token
header.Related issues
Fixes #143